SlideShare a Scribd company logo
1 of 9
---------------------------------------------------------

15 SQL QUERIES:

---------------------------------------------------------



1)Names of Customer who have ordered items from dept having DID='D00001'



select CNAME from customer1 CID IN(select CID from cust_dept1 where DID='D00001');



O/P:



CNAME

--------------------

Bharti

Ena



2 rows selected.



2)Find the type of books in which Tina is interested



select BOOK_NAME from books1 where DID IN (Select DID from cust_dept1 where CID IN(Select CID
from customer1 where CNAME='Tina'));



O/P:



BOOK_NAME
--------------------

biography

fiction



2 rows selected.



3)Type of Clothing selected by Nehal



select CLOTH_NAME from clothing1 where DID IN (Select DID from cust_dept1 where CID IN(Select CID
from customer1 where CNAME='Nehal'));



O/P:



CLOTH_NAME

--------------------

Formals

Traditional

Jeans



1 row selected.



4)Customers who dont stay in Mumbai and Delhi



select CNAME from customer where CADDRESS NOT IN('Mumbai','Delhi');



O/P:
CNAME

--------------------

Ena

Nehal



2 rows selected.



5)Customers who are interested in TV whose inches are in the range of 30



select CNAME from customer where CID IN (Select CID from cust_dept where DID IN(Select DID from
electronics where ENAME='TV' and EID IN(Select EID from TV where inches like('3%'))));



O/P:



CNAME

--------------------

Bharti

Ena



2 rows selected.



6)Mobile having bluetooth connectivity



select * from mobile where connectivity like ('B%');
O/P:



CONNECTIVITY              EID

-------------------- ----------

Bluetooth             E00001

Bluetooth             E00001



2 rows selected.



7)Customers whose name end with 'na'



select CID,CNAME from customer where CNAME like ('%na');



O/P:



CID       CNAME

---------- --------------------

C00002       Ena

C00004       Krina

C00005       Tina



3 rows selected.



8)Items belonging to Electronics department
select ENAME from electronics where Exists(Select DID from cust_dept where
electronics.DID=cust_dept.DID ) ;



O/P:



ENAME

--------------------

MOBILE

cameras

TV



3 rows selected.



9)Details of Items pressent in mobile section of Electronics department



Select * from electronics e ,mobile m where e.EID=m.EID;



O/P:



EID       ENAME                     ECOST DID           CONNECTIVITY               EID

---------- -------------------- ---------- ---------- -------------------- ----------

E00001       MOBILE                    10000 D00001           Bluetooth                 E00001

E00001       MOBILE                    10000 D00001           Infrared             E00001

E00001       MOBILE                    10000 D00001           Bluetooth                 E00001



3 rows selected.
10)Ascending order



select * from customer order by CNAME;



O/P:



CID       CNAME                 CADDRESS

---------- -------------------- ------------------------------

C00001       Bharti              Mumbai

C00002       Ena                Pune

C00004       Krina              Delhi

C00003       Nehal               Banglore

C00005       Tina               Mumbai



5 rows selected.



11)Descending Order



select * from customer order by CNAME desc;



O/P:



CID       CNAME                 CADDRESS

---------- -------------------- ------------------------------
C00005       Tina               Mumbai

C00003       Nehal               Banglore

C00004       Krina              Delhi

C00002       Ena                Pune

C00001       Bharti              Mumbai



5 rows selected.



12)Details about which customers interested in which department (use of using clause)



select CID,c.CNAME,c.CADDRESS,d.DID from customer c join cust_dept d using (CID);



O/P:

CID       CNAME                 CADDRESS                        DID

---------- -------------------- ------------------------------ ----------

C00001       Bharti              Mumbai                        D00001

C00002       Ena                Pune                       D00001

C00003       Nehal               Banglore                     D00002

C00004       Krina              Delhi                      D00002

C00005       Tina               Mumbai                        D00003



5 rows selected.




13)Customers interested in mobiles having connectivity='bluetooth'
select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from
electronics where EID in(Select EID from mobile where connectivity='Bluetooth')));




O/P:



CID       CNAME                 CADDRESS

---------- -------------------- ------------------------------

C00001       Bharti              Mumbai

C00002       Ena                Pune



2 rows selected.




14)Customers interested in biography section of books department



select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from books
where BOOK_ID in (Select BOOK_ID from biography where TYPE='Freedom Fighter')));



O/P:



CID       CNAME                 CADDRESS

---------- -------------------- ------------------------------

C00005       Tina               Mumbai
1 row selected.




15)Electronic items having cost > 10000



select * from electronics where ECOST > 10000



O/P:



EID       ENAME                     ECOST DID

---------- -------------------- ---------- ----------

E00002       cameras                   20000 D00001

E00003       TV                    15000 D00001



2 rows selected.

More Related Content

Viewers also liked

Call Sheet Field
Call Sheet FieldCall Sheet Field
Call Sheet Fieldsamjewiss
 
Photo Essay
Photo EssayPhoto Essay
Photo Essayderek20
 
Focus group-questionnaire
Focus group-questionnaireFocus group-questionnaire
Focus group-questionnaireJwbread
 
cuenta
cuentacuenta
cuentaj0ofer
 
Questionnaire
QuestionnaireQuestionnaire
QuestionnaireJwbread
 
Music magazine questionnaire
Music magazine questionnaireMusic magazine questionnaire
Music magazine questionnaireizzy_hennessy
 
Contents page editing
Contents page editingContents page editing
Contents page editingizzy_hennessy
 
The Scandinavian Company Skin Arctica
The Scandinavian Company Skin ArcticaThe Scandinavian Company Skin Arctica
The Scandinavian Company Skin Arcticacarinawood888
 
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...Social Media Schweiz
 
Analysis of lady gaga just dance2
Analysis of lady gaga just dance2Analysis of lady gaga just dance2
Analysis of lady gaga just dance2demioshea
 
Proyecto de conducta
Proyecto de conductaProyecto de conducta
Proyecto de conductachuyzai
 

Viewers also liked (20)

Call Sheet Field
Call Sheet FieldCall Sheet Field
Call Sheet Field
 
Photo Essay
Photo EssayPhoto Essay
Photo Essay
 
Initial Ideas
Initial IdeasInitial Ideas
Initial Ideas
 
Presentation1
Presentation1Presentation1
Presentation1
 
Focus group-questionnaire
Focus group-questionnaireFocus group-questionnaire
Focus group-questionnaire
 
Social groups
Social groupsSocial groups
Social groups
 
Evaluation
EvaluationEvaluation
Evaluation
 
cuenta
cuentacuenta
cuenta
 
Questionnaire
QuestionnaireQuestionnaire
Questionnaire
 
Social groups
Social groupsSocial groups
Social groups
 
Estopa
EstopaEstopa
Estopa
 
Music magazine questionnaire
Music magazine questionnaireMusic magazine questionnaire
Music magazine questionnaire
 
Contents page editing
Contents page editingContents page editing
Contents page editing
 
The Scandinavian Company Skin Arctica
The Scandinavian Company Skin ArcticaThe Scandinavian Company Skin Arctica
The Scandinavian Company Skin Arctica
 
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...
Facebook: Entwicklung von ausgesuchten Schweizer Markenfanseiten (Update: Jun...
 
Lyric breakdown
Lyric breakdownLyric breakdown
Lyric breakdown
 
Analysis of lady gaga just dance2
Analysis of lady gaga just dance2Analysis of lady gaga just dance2
Analysis of lady gaga just dance2
 
Proyecto de conducta
Proyecto de conductaProyecto de conducta
Proyecto de conducta
 
25 de abril ii
25 de abril ii25 de abril ii
25 de abril ii
 
Corridor recording
Corridor recordingCorridor recording
Corridor recording
 

Similar to Queries2

Bala ji microtechnologies cameralink line scan camera korea
Bala ji microtechnologies cameralink line scan camera koreaBala ji microtechnologies cameralink line scan camera korea
Bala ji microtechnologies cameralink line scan camera koreabalajibmt02
 
Bmt 2098 c-a-line_scan_camera_user_manual
Bmt 2098 c-a-line_scan_camera_user_manualBmt 2098 c-a-line_scan_camera_user_manual
Bmt 2098 c-a-line_scan_camera_user_manualBalajimicrotechnologies
 
Bala ji microtechnologies analog line scan camera korea
Bala ji microtechnologies analog line scan camera koreaBala ji microtechnologies analog line scan camera korea
Bala ji microtechnologies analog line scan camera koreabalajibmt02
 
DetailsiBeacon_endocsSetupBeaconInIOS.pdf
DetailsiBeacon_endocsSetupBeaconInIOS.pdfDetailsiBeacon_endocsSetupBeaconInIOS.pdf
DetailsiBeacon_endocsSetupBeaconInIOS.pdfSomnathKhamaru1
 
Pmcs user exits
Pmcs user exitsPmcs user exits
Pmcs user exitsJohn Peter
 
Ks 858 e intelligent network alarm systems panel user's manual
Ks 858 e intelligent network alarm systems panel user's manualKs 858 e intelligent network alarm systems panel user's manual
Ks 858 e intelligent network alarm systems panel user's manualVedard Security Alarm System Store
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所Hiroshi Sekiguchi
 
Auto dial-er Home security
Auto dial-er Home securityAuto dial-er Home security
Auto dial-er Home securityvaibhav jindal
 
zte umts-cs-call-drop-analysis-guide-zte
zte umts-cs-call-drop-analysis-guide-ztezte umts-cs-call-drop-analysis-guide-zte
zte umts-cs-call-drop-analysis-guide-zte3ggprs
 
Electronics for-you-projects-and-ideas-2000
Electronics for-you-projects-and-ideas-2000Electronics for-you-projects-and-ideas-2000
Electronics for-you-projects-and-ideas-2000nonshahid
 
Electronics for you projects and ideas 2000 (malestrom)
Electronics for you projects and ideas 2000 (malestrom)Electronics for you projects and ideas 2000 (malestrom)
Electronics for you projects and ideas 2000 (malestrom)Rohit Chintu
 
2000 circuit project
2000 circuit project2000 circuit project
2000 circuit projectQuangTrnMinh3
 
Electronics for you (jan dec 2000)
Electronics for you (jan dec 2000)Electronics for you (jan dec 2000)
Electronics for you (jan dec 2000)vikas_kumar10Aug
 
Microsoft Word Mobile Multi Media Applications
Microsoft Word   Mobile Multi Media ApplicationsMicrosoft Word   Mobile Multi Media Applications
Microsoft Word Mobile Multi Media Applicationskkkseld
 

Similar to Queries2 (20)

Sql queries
Sql queriesSql queries
Sql queries
 
Bala ji microtechnologies cameralink line scan camera korea
Bala ji microtechnologies cameralink line scan camera koreaBala ji microtechnologies cameralink line scan camera korea
Bala ji microtechnologies cameralink line scan camera korea
 
Bmt 2098 c-a-line_scan_camera_user_manual
Bmt 2098 c-a-line_scan_camera_user_manualBmt 2098 c-a-line_scan_camera_user_manual
Bmt 2098 c-a-line_scan_camera_user_manual
 
Bala ji microtechnologies analog line scan camera korea
Bala ji microtechnologies analog line scan camera koreaBala ji microtechnologies analog line scan camera korea
Bala ji microtechnologies analog line scan camera korea
 
DetailsiBeacon_endocsSetupBeaconInIOS.pdf
DetailsiBeacon_endocsSetupBeaconInIOS.pdfDetailsiBeacon_endocsSetupBeaconInIOS.pdf
DetailsiBeacon_endocsSetupBeaconInIOS.pdf
 
Pmcs user exits
Pmcs user exitsPmcs user exits
Pmcs user exits
 
Ks 858 e intelligent network alarm systems panel user's manual
Ks 858 e intelligent network alarm systems panel user's manualKs 858 e intelligent network alarm systems panel user's manual
Ks 858 e intelligent network alarm systems panel user's manual
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
 
Auto dial-er Home security
Auto dial-er Home securityAuto dial-er Home security
Auto dial-er Home security
 
zte umts-cs-call-drop-analysis-guide-zte
zte umts-cs-call-drop-analysis-guide-ztezte umts-cs-call-drop-analysis-guide-zte
zte umts-cs-call-drop-analysis-guide-zte
 
Electronics for-you-projects-and-ideas-2000
Electronics for-you-projects-and-ideas-2000Electronics for-you-projects-and-ideas-2000
Electronics for-you-projects-and-ideas-2000
 
Electronics for you projects and ideas 2000 (malestrom)
Electronics for you projects and ideas 2000 (malestrom)Electronics for you projects and ideas 2000 (malestrom)
Electronics for you projects and ideas 2000 (malestrom)
 
Cn51 configuração
Cn51 configuraçãoCn51 configuração
Cn51 configuração
 
Mc18 Zebra
Mc18 ZebraMc18 Zebra
Mc18 Zebra
 
BTS Key Mgt
BTS Key MgtBTS Key Mgt
BTS Key Mgt
 
Resume Local canada
Resume Local canadaResume Local canada
Resume Local canada
 
2000 circuit project
2000 circuit project2000 circuit project
2000 circuit project
 
Projetos eletrônicos
Projetos eletrônicosProjetos eletrônicos
Projetos eletrônicos
 
Electronics for you (jan dec 2000)
Electronics for you (jan dec 2000)Electronics for you (jan dec 2000)
Electronics for you (jan dec 2000)
 
Microsoft Word Mobile Multi Media Applications
Microsoft Word   Mobile Multi Media ApplicationsMicrosoft Word   Mobile Multi Media Applications
Microsoft Word Mobile Multi Media Applications
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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?Antenna Manufacturer Coco
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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 MenDelhi Call girls
 
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...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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 2024Rafal Los
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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 slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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.pdfUK Journal
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
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...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 

Queries2

  • 1. --------------------------------------------------------- 15 SQL QUERIES: --------------------------------------------------------- 1)Names of Customer who have ordered items from dept having DID='D00001' select CNAME from customer1 CID IN(select CID from cust_dept1 where DID='D00001'); O/P: CNAME -------------------- Bharti Ena 2 rows selected. 2)Find the type of books in which Tina is interested select BOOK_NAME from books1 where DID IN (Select DID from cust_dept1 where CID IN(Select CID from customer1 where CNAME='Tina')); O/P: BOOK_NAME
  • 2. -------------------- biography fiction 2 rows selected. 3)Type of Clothing selected by Nehal select CLOTH_NAME from clothing1 where DID IN (Select DID from cust_dept1 where CID IN(Select CID from customer1 where CNAME='Nehal')); O/P: CLOTH_NAME -------------------- Formals Traditional Jeans 1 row selected. 4)Customers who dont stay in Mumbai and Delhi select CNAME from customer where CADDRESS NOT IN('Mumbai','Delhi'); O/P:
  • 3. CNAME -------------------- Ena Nehal 2 rows selected. 5)Customers who are interested in TV whose inches are in the range of 30 select CNAME from customer where CID IN (Select CID from cust_dept where DID IN(Select DID from electronics where ENAME='TV' and EID IN(Select EID from TV where inches like('3%')))); O/P: CNAME -------------------- Bharti Ena 2 rows selected. 6)Mobile having bluetooth connectivity select * from mobile where connectivity like ('B%');
  • 4. O/P: CONNECTIVITY EID -------------------- ---------- Bluetooth E00001 Bluetooth E00001 2 rows selected. 7)Customers whose name end with 'na' select CID,CNAME from customer where CNAME like ('%na'); O/P: CID CNAME ---------- -------------------- C00002 Ena C00004 Krina C00005 Tina 3 rows selected. 8)Items belonging to Electronics department
  • 5. select ENAME from electronics where Exists(Select DID from cust_dept where electronics.DID=cust_dept.DID ) ; O/P: ENAME -------------------- MOBILE cameras TV 3 rows selected. 9)Details of Items pressent in mobile section of Electronics department Select * from electronics e ,mobile m where e.EID=m.EID; O/P: EID ENAME ECOST DID CONNECTIVITY EID ---------- -------------------- ---------- ---------- -------------------- ---------- E00001 MOBILE 10000 D00001 Bluetooth E00001 E00001 MOBILE 10000 D00001 Infrared E00001 E00001 MOBILE 10000 D00001 Bluetooth E00001 3 rows selected.
  • 6. 10)Ascending order select * from customer order by CNAME; O/P: CID CNAME CADDRESS ---------- -------------------- ------------------------------ C00001 Bharti Mumbai C00002 Ena Pune C00004 Krina Delhi C00003 Nehal Banglore C00005 Tina Mumbai 5 rows selected. 11)Descending Order select * from customer order by CNAME desc; O/P: CID CNAME CADDRESS ---------- -------------------- ------------------------------
  • 7. C00005 Tina Mumbai C00003 Nehal Banglore C00004 Krina Delhi C00002 Ena Pune C00001 Bharti Mumbai 5 rows selected. 12)Details about which customers interested in which department (use of using clause) select CID,c.CNAME,c.CADDRESS,d.DID from customer c join cust_dept d using (CID); O/P: CID CNAME CADDRESS DID ---------- -------------------- ------------------------------ ---------- C00001 Bharti Mumbai D00001 C00002 Ena Pune D00001 C00003 Nehal Banglore D00002 C00004 Krina Delhi D00002 C00005 Tina Mumbai D00003 5 rows selected. 13)Customers interested in mobiles having connectivity='bluetooth'
  • 8. select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from electronics where EID in(Select EID from mobile where connectivity='Bluetooth'))); O/P: CID CNAME CADDRESS ---------- -------------------- ------------------------------ C00001 Bharti Mumbai C00002 Ena Pune 2 rows selected. 14)Customers interested in biography section of books department select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from books where BOOK_ID in (Select BOOK_ID from biography where TYPE='Freedom Fighter'))); O/P: CID CNAME CADDRESS ---------- -------------------- ------------------------------ C00005 Tina Mumbai
  • 9. 1 row selected. 15)Electronic items having cost > 10000 select * from electronics where ECOST > 10000 O/P: EID ENAME ECOST DID ---------- -------------------- ---------- ---------- E00002 cameras 20000 D00001 E00003 TV 15000 D00001 2 rows selected.