SlideShare a Scribd company logo
Chapter – 7
Working with Two Result
Sets
1. Question
CustomerID Name Country Age Registration_date
1 Daniel USA 42 11-Nov-2018
2 Martin USA 42 1-Jan-2019
3 Amitabh India 34 NULL
4 Amit India 18 1-Jan-2019
5 Dilip India NULL 24-Feb-2019
6 Advik India 11 12-Dec-2018
7 Avit NULL NULL NULL
8 Agrim India 4 NULL
Customer Table
Expected Output
Input Data and Expected Output
OrderID CustomerID Amount ProductName
1 1 120 Cold Drink
2 1 250 Biscuit
3 2 120 Cold Drink
4 10 25 Flower
5 3 110 Apple
6 2 25 Flower
Orders Table
CustomerID
1
2
3
Solution and Query Execution Result
Concept Generalization
Query Solution
2. Question
CustomerID
4
5
6
7
8
CustomerID Name Country Age Registration_date
1 Daniel USA 42 11-Nov-2018
2 Martin USA 42 1-Jan-2019
3 Amitabh India 34 NULL
4 Amit India 18 1-Jan-2019
5 Dilip India NULL 24-Feb-2019
6 Advik India 11 12-Dec-2018
7 Avit NULL NULL NULL
8 Agrim India 4 NULL
Customer Table
Expected Output
Input Data and Expected Output
OrderID CustomerID Amount ProductName
1 1 120 Cold Drink
2 1 250 Biscuit
3 2 120 Cold Drink
4 10 25 Flower
5 3 110 Apple
6 2 25 Flower
Orders Table
Solution and Query Execution Result
Concept Generalization
Query Solution
3. Question
CustomerID
10
CustomerID Name Country Age Registration_date
1 Daniel USA 42 11-Nov-2018
2 Martin USA 42 1-Jan-2019
3 Amitabh India 34 NULL
4 Amit India 18 1-Jan-2019
5 Dilip India NULL 24-Feb-2019
6 Advik India 11 12-Dec-2018
7 Avit NULL NULL NULL
8 Agrim India 4 NULL
Customer Table
Expected Output
Input Data and Expected Output
OrderID CustomerID Amount ProductName
1 1 120 Cold Drink
2 1 250 Biscuit
3 2 120 Cold Drink
4 10 25 Flower
5 3 110 Apple
6 2 25 Flower
Orders Table
Solution and Query Execution Result
Concept Generalization
Query Solution
Author is M.Tech. from BITS Pilani in software
systems. He is currently working as
Associate Technical Architect in CMM Level 5
company and have more than 15 years of
experience in software development and
practices.
Please reach out to Author at
ars.sqb@gmail.com if you have any query /
suggestion / details which you would like to
share.
About the Author
Why to Read Book
Who can Read Book
Features of the Book
How to buy the Book and benefit after purchase
Want to learn more about
our 30 hours training
program
30 Hours Training Schedule for SQL Server 2017
Serial # Agenda Duration
(Hours)
Agenda Detail
1 Installation of Microsoft SQL Server 2017 1.0  We will make sure installation done on
every machine
2 TSQL-Selection 2.0  Record Selection
 Record Alias
 Record Ordering
 Select Top N record
 Record Distinct
3 TSQL-Filter 2.0  Record filter on Numeric column
 Record filter on Date column
 Record filter on String column
4 TSQL-Multiple Filter 1.5  Record filter using AND operator
 Record filter using OR operator
 Record filter using NOT operator
5 TSQL-Grouping 1.5  Count, Count Distinct, Min, Max, Sum,
Average On Table
 Record Grouping and then Count, Min,
Max, Sum, Average On Table
 Record Grouping and then Count, Min,
Max, Sum, Average On Table and
Finally Filter
6 TSQL-Joining 2.0  Record Join (Left join, Right join, Full
join, Cross join, Cross Apply and Outer
Apply)
 Using Exists and Not Exists
30 Hours Training Schedule for SQL Server 2017
Serial # Agenda Duration
(Hours)
Agenda Detail
7 TSQL -Various Operation 3.0  Working with Date
 String Operation
 Using ISNULL
 Using Case
 Using IIF
 Converting column value to other Data
Type
 Sequencing on Table records
8 Working with two result sets 1.5  Using Intersect
 Using Except
 Using Union All
 Using Union
9 DDL-Operations 2.0  Working on Database
 Working on Table
 Working on Various Keys
 Working on Index
10 DML-Operations 2.0  Record Insertion
 Record Insertion using Select INTO
 Record Update
 Record Delete
 Truncate Table
30 Hours Training Schedule for SQL Server 2017
Serial # Agenda Duration
(Hours)
Agenda Detail
11 Stored Procedure 4.0  Working with Variable
 Create Stored Procedure
 Alter Stored Procedure
 Using Temporary Table/ Table Variable
 Using If Else
 Loop Handling
 Exception Handling
 Transaction Management
12 Function 1.5  Scalar Function
 Inline Table Valued Function
 Multi-Statement Table Valued Function
13 Trigger 2.5  After Trigger: INSERT
 After Trigger: UPDATE
 After Trigger: DELETE
 After Trigger: Magic Tables
 Instead of Trigger: INSERT
 Instead of Trigger: UPDATE
 Instead Of Trigger: DELETE
14 View 1.0  Create View
 Alter View
15 Troubleshooting and Performance 2.5  Basic Troubleshooting
 Stored Procedure Debugging
 Function Debugging
 Query Performance
 Query Performance tool
Total 30

More Related Content

PPTX
Chapter 1 TSQL - SELECTION
PPTX
Chapter 4 TSQL-Grouping
PPTX
Chapter 12 Trigger
PPTX
Chapter 9 DML-Operations
PPTX
Chapter 14 Troubleshooting and Performance
PPTX
Chapter 10 Stored Procedure
PPTX
U-SQL Does SQL (SQLBits 2016)
PDF
Tech Jam 01 - Database Querying
Chapter 1 TSQL - SELECTION
Chapter 4 TSQL-Grouping
Chapter 12 Trigger
Chapter 9 DML-Operations
Chapter 14 Troubleshooting and Performance
Chapter 10 Stored Procedure
U-SQL Does SQL (SQLBits 2016)
Tech Jam 01 - Database Querying

Similar to Chapter 7 Working with two result sets (20)

PDF
45 Essential SQL Interview Questions
PPT
Ch7
PPTX
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
PPTX
Database Management System - SQL Advanced Training
PPT
SQL200.2 Module 2
DOCX
Sql interview prep
DOC
SQL Joins
PPT
Advanced Sql Training
PDF
SQL CHEAT SHEET
PPTX
1. dml select statement reterive data
PDF
Sql ch 5
PDF
DBMS Nested & Sub Queries Set operations
PPTX
Major advancements in Apache Hive towards full support of SQL compliance
PPTX
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PDF
IMPORTAnt sql ques for data analyst interview.pdf
PPT
hoffer_edm_pp_ch07 (1).ppt
PPTX
Querying_with_T-SQL_-_03 (1).pptx
PPTX
Querying_with_T-SQL_-_03.pptx
PPT
Transact SQL (T-SQL) for Beginners (A New Hope)
PPTX
Day-2 SQL Theory_V1.pptx
45 Essential SQL Interview Questions
Ch7
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Database Management System - SQL Advanced Training
SQL200.2 Module 2
Sql interview prep
SQL Joins
Advanced Sql Training
SQL CHEAT SHEET
1. dml select statement reterive data
Sql ch 5
DBMS Nested & Sub Queries Set operations
Major advancements in Apache Hive towards full support of SQL compliance
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
IMPORTAnt sql ques for data analyst interview.pdf
hoffer_edm_pp_ch07 (1).ppt
Querying_with_T-SQL_-_03 (1).pptx
Querying_with_T-SQL_-_03.pptx
Transact SQL (T-SQL) for Beginners (A New Hope)
Day-2 SQL Theory_V1.pptx
Ad

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Geodesy 1.pptx...............................................
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
additive manufacturing of ss316l using mig welding
DOCX
573137875-Attendance-Management-System-original
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Well-logging-methods_new................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Current and future trends in Computer Vision.pptx
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
composite construction of structures.pdf
PPTX
Artificial Intelligence
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
R24 SURVEYING LAB MANUAL for civil enggi
Geodesy 1.pptx...............................................
Operating System & Kernel Study Guide-1 - converted.pdf
Sustainable Sites - Green Building Construction
additive manufacturing of ss316l using mig welding
573137875-Attendance-Management-System-original
Foundation to blockchain - A guide to Blockchain Tech
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Well-logging-methods_new................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Current and future trends in Computer Vision.pptx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
composite construction of structures.pdf
Artificial Intelligence
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Safety Seminar civil to be ensured for safe working.
Model Code of Practice - Construction Work - 21102022 .pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Ad

Chapter 7 Working with two result sets

  • 1. Chapter – 7 Working with Two Result Sets
  • 3. CustomerID Name Country Age Registration_date 1 Daniel USA 42 11-Nov-2018 2 Martin USA 42 1-Jan-2019 3 Amitabh India 34 NULL 4 Amit India 18 1-Jan-2019 5 Dilip India NULL 24-Feb-2019 6 Advik India 11 12-Dec-2018 7 Avit NULL NULL NULL 8 Agrim India 4 NULL Customer Table Expected Output Input Data and Expected Output OrderID CustomerID Amount ProductName 1 1 120 Cold Drink 2 1 250 Biscuit 3 2 120 Cold Drink 4 10 25 Flower 5 3 110 Apple 6 2 25 Flower Orders Table CustomerID 1 2 3
  • 4. Solution and Query Execution Result
  • 7. CustomerID 4 5 6 7 8 CustomerID Name Country Age Registration_date 1 Daniel USA 42 11-Nov-2018 2 Martin USA 42 1-Jan-2019 3 Amitabh India 34 NULL 4 Amit India 18 1-Jan-2019 5 Dilip India NULL 24-Feb-2019 6 Advik India 11 12-Dec-2018 7 Avit NULL NULL NULL 8 Agrim India 4 NULL Customer Table Expected Output Input Data and Expected Output OrderID CustomerID Amount ProductName 1 1 120 Cold Drink 2 1 250 Biscuit 3 2 120 Cold Drink 4 10 25 Flower 5 3 110 Apple 6 2 25 Flower Orders Table
  • 8. Solution and Query Execution Result
  • 11. CustomerID 10 CustomerID Name Country Age Registration_date 1 Daniel USA 42 11-Nov-2018 2 Martin USA 42 1-Jan-2019 3 Amitabh India 34 NULL 4 Amit India 18 1-Jan-2019 5 Dilip India NULL 24-Feb-2019 6 Advik India 11 12-Dec-2018 7 Avit NULL NULL NULL 8 Agrim India 4 NULL Customer Table Expected Output Input Data and Expected Output OrderID CustomerID Amount ProductName 1 1 120 Cold Drink 2 1 250 Biscuit 3 2 120 Cold Drink 4 10 25 Flower 5 3 110 Apple 6 2 25 Flower Orders Table
  • 12. Solution and Query Execution Result
  • 14. Author is M.Tech. from BITS Pilani in software systems. He is currently working as Associate Technical Architect in CMM Level 5 company and have more than 15 years of experience in software development and practices. Please reach out to Author at ars.sqb@gmail.com if you have any query / suggestion / details which you would like to share. About the Author
  • 15. Why to Read Book Who can Read Book
  • 17. How to buy the Book and benefit after purchase
  • 18. Want to learn more about our 30 hours training program
  • 19. 30 Hours Training Schedule for SQL Server 2017 Serial # Agenda Duration (Hours) Agenda Detail 1 Installation of Microsoft SQL Server 2017 1.0  We will make sure installation done on every machine 2 TSQL-Selection 2.0  Record Selection  Record Alias  Record Ordering  Select Top N record  Record Distinct 3 TSQL-Filter 2.0  Record filter on Numeric column  Record filter on Date column  Record filter on String column 4 TSQL-Multiple Filter 1.5  Record filter using AND operator  Record filter using OR operator  Record filter using NOT operator 5 TSQL-Grouping 1.5  Count, Count Distinct, Min, Max, Sum, Average On Table  Record Grouping and then Count, Min, Max, Sum, Average On Table  Record Grouping and then Count, Min, Max, Sum, Average On Table and Finally Filter 6 TSQL-Joining 2.0  Record Join (Left join, Right join, Full join, Cross join, Cross Apply and Outer Apply)  Using Exists and Not Exists
  • 20. 30 Hours Training Schedule for SQL Server 2017 Serial # Agenda Duration (Hours) Agenda Detail 7 TSQL -Various Operation 3.0  Working with Date  String Operation  Using ISNULL  Using Case  Using IIF  Converting column value to other Data Type  Sequencing on Table records 8 Working with two result sets 1.5  Using Intersect  Using Except  Using Union All  Using Union 9 DDL-Operations 2.0  Working on Database  Working on Table  Working on Various Keys  Working on Index 10 DML-Operations 2.0  Record Insertion  Record Insertion using Select INTO  Record Update  Record Delete  Truncate Table
  • 21. 30 Hours Training Schedule for SQL Server 2017 Serial # Agenda Duration (Hours) Agenda Detail 11 Stored Procedure 4.0  Working with Variable  Create Stored Procedure  Alter Stored Procedure  Using Temporary Table/ Table Variable  Using If Else  Loop Handling  Exception Handling  Transaction Management 12 Function 1.5  Scalar Function  Inline Table Valued Function  Multi-Statement Table Valued Function 13 Trigger 2.5  After Trigger: INSERT  After Trigger: UPDATE  After Trigger: DELETE  After Trigger: Magic Tables  Instead of Trigger: INSERT  Instead of Trigger: UPDATE  Instead Of Trigger: DELETE 14 View 1.0  Create View  Alter View 15 Troubleshooting and Performance 2.5  Basic Troubleshooting  Stored Procedure Debugging  Function Debugging  Query Performance  Query Performance tool Total 30