SlideShare ist ein Scribd-Unternehmen logo
1 von 5
1000 SQL Queries
Srinimf.com
Join Example
EMP_NM EMP_JB SELECT nm.id ANSWER
+----------+ +--------+ ,nm.name ================
|ID|NAME | |ID|JOB | ,jb.job ID NAME JOB
|--|-------| |--|-----| FROM emp_nm nm -- ------- -----
|10|Sanders| |10|Sales| ,emp_jb jb 10 Sanders Sales
|20|Pernal | |20|Clerk| WHERE nm.id = jb.id 20 Pernal Clerk
|50|Hanes | +--------+ ORDER BY 1;
+----------+
Left Outer Join example
EMP_NM EMP_JB SELECT nm.id ANSWER
+----------+ +--------+ ,nm.name ================
|ID|NAME | |ID|JOB | ,jb.job ID NAME JOB
|--|-------| |--|-----| FROM emp_nm nm -- ------- -----
|10|Sanders| |10|Sales| LEFT OUTER JOIN 10 Sanders Sales
|20|Pernal | |20|Clerk| emp_jb jb 20 Pernal Clerk
|50|Hanes | +--------+ ON nm.id = jb.id 50 Hanes -
+----------+ ORDER BY nm.id;
Sub Query Example
EMP_NM EMP_JB SELECT * ANSWER
+----------+ +--------+ FROM emp_nm nm ========
|ID|NAME | |ID|JOB | WHERE NOT EXISTS ID NAME
|--|-------| |--|-----| (SELECT * == =====
|10|Sanders| |10|Sales| FROM emp_jb jb 50 Hanes
|20|Pernal | |20|Clerk| WHERE nm.id = jb.id)
|50|Hanes | +--------+ ORDER BY id;
+----------+
Thank you
Download
1000 SQL Queries here
Srinimf.com

Weitere ähnliche Inhalte

Andere mochten auch

Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
Pyadav010186
 
DB2 Systems Programming Tools of the Trade NA07B03
DB2 Systems Programming Tools of the Trade NA07B03DB2 Systems Programming Tools of the Trade NA07B03
DB2 Systems Programming Tools of the Trade NA07B03
Linda Hagedorn
 

Andere mochten auch (12)

Sql queries
Sql queriesSql queries
Sql queries
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
 
Learn VBScript – Part 1 of 4
Learn VBScript – Part 1 of 4Learn VBScript – Part 1 of 4
Learn VBScript – Part 1 of 4
 
Sql server performance appraisal
Sql server performance appraisalSql server performance appraisal
Sql server performance appraisal
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
 
Rexx
RexxRexx
Rexx
 
Rexx Shih
Rexx ShihRexx Shih
Rexx Shih
 
The Easytrieve Presention by Srinimf
The Easytrieve Presention by SrinimfThe Easytrieve Presention by Srinimf
The Easytrieve Presention by Srinimf
 
Summary session 5
Summary session 5Summary session 5
Summary session 5
 
DB2 Systems Programming Tools of the Trade NA07B03
DB2 Systems Programming Tools of the Trade NA07B03DB2 Systems Programming Tools of the Trade NA07B03
DB2 Systems Programming Tools of the Trade NA07B03
 
SAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSAS Mainframe -Program-Tips
SAS Mainframe -Program-Tips
 

Mehr von Srinimf-Slides

Mehr von Srinimf-Slides (20)

software-life-cycle.pptx
software-life-cycle.pptxsoftware-life-cycle.pptx
software-life-cycle.pptx
 
Python Tutorial Questions part-1
Python Tutorial Questions part-1Python Tutorial Questions part-1
Python Tutorial Questions part-1
 
Cics testing and debugging-session 7
Cics testing and debugging-session 7Cics testing and debugging-session 7
Cics testing and debugging-session 7
 
CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6
 
Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5
 
Cics data access-session 4
Cics data access-session 4Cics data access-session 4
Cics data access-session 4
 
CICS basic mapping support - session 3
CICS basic mapping support - session 3CICS basic mapping support - session 3
CICS basic mapping support - session 3
 
Cics application programming - session 2
Cics   application programming - session 2Cics   application programming - session 2
Cics application programming - session 2
 
CICS basics overview session-1
CICS basics overview session-1CICS basics overview session-1
CICS basics overview session-1
 
The best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresherThe best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresher
 
The best ETL questions in a nut shell
The best ETL questions in a nut shellThe best ETL questions in a nut shell
The best ETL questions in a nut shell
 
How To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven DaysHow To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven Days
 
PL/SQL Interview Questions
PL/SQL Interview QuestionsPL/SQL Interview Questions
PL/SQL Interview Questions
 
Macro teradata
Macro teradataMacro teradata
Macro teradata
 
DB2-SQL Part-2
DB2-SQL Part-2DB2-SQL Part-2
DB2-SQL Part-2
 
DB2 SQL-Part-1
DB2 SQL-Part-1DB2 SQL-Part-1
DB2 SQL-Part-1
 
Teradata - Utilities
Teradata - UtilitiesTeradata - Utilities
Teradata - Utilities
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Hirarchical vs RDBMS
Hirarchical vs RDBMSHirarchical vs RDBMS
Hirarchical vs RDBMS
 
SRINIMF - An Overview
SRINIMF - An OverviewSRINIMF - An Overview
SRINIMF - An Overview
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

100 sql queries

  • 2. Join Example EMP_NM EMP_JB SELECT nm.id ANSWER +----------+ +--------+ ,nm.name ================ |ID|NAME | |ID|JOB | ,jb.job ID NAME JOB |--|-------| |--|-----| FROM emp_nm nm -- ------- ----- |10|Sanders| |10|Sales| ,emp_jb jb 10 Sanders Sales |20|Pernal | |20|Clerk| WHERE nm.id = jb.id 20 Pernal Clerk |50|Hanes | +--------+ ORDER BY 1; +----------+
  • 3. Left Outer Join example EMP_NM EMP_JB SELECT nm.id ANSWER +----------+ +--------+ ,nm.name ================ |ID|NAME | |ID|JOB | ,jb.job ID NAME JOB |--|-------| |--|-----| FROM emp_nm nm -- ------- ----- |10|Sanders| |10|Sales| LEFT OUTER JOIN 10 Sanders Sales |20|Pernal | |20|Clerk| emp_jb jb 20 Pernal Clerk |50|Hanes | +--------+ ON nm.id = jb.id 50 Hanes - +----------+ ORDER BY nm.id;
  • 4. Sub Query Example EMP_NM EMP_JB SELECT * ANSWER +----------+ +--------+ FROM emp_nm nm ======== |ID|NAME | |ID|JOB | WHERE NOT EXISTS ID NAME |--|-------| |--|-----| (SELECT * == ===== |10|Sanders| |10|Sales| FROM emp_jb jb 50 Hanes |20|Pernal | |20|Clerk| WHERE nm.id = jb.id) |50|Hanes | +--------+ ORDER BY id; +----------+
  • 5. Thank you Download 1000 SQL Queries here Srinimf.com