Your SlideShare is downloading. ×
A
A
A
A
A
A
A
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

A

59

Published on

Published in: Education, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
59
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1) What are the names of customers who have sent packages (shipments) to Sioux City? SQL> Selectcust_id,cust_name from CUSTOMERsss where cust_id in (select cust_id from shipmentsss where destination = 'Sioux'); Ans:-no rows selected 2)To what destinations have companies with revenue less than $1 million sent packages? SQL>select distinct(destination) from shipmentsss where cust_id in (select cust_id from customersss where annual_revenue< 10000000); DESTINATION --------------London Sioux City Baltimore Panama City Rome San Francisco St.Louis Los Angeles Manhattan Paris 10 rows selected. 3)What are the names and populations of cities that have received shipments weighing over 100 pounds? SQL>select city_name,population from citysss where city_name in (select destination from shipmentsss where weight > 100); CITY_NAME POPULATION ------------------------------ ---------London Manhattan 100000000 10000000
  • 2. Rome San Francisco Sioux City 200000000 20000000 5000000000 4)> select cust_id,cust_name from CUSTOMERsss where annual_revenue> 5000000 and cust_id in ( select cust_id from shipmentsss where weight <1); Ans:-no rows selected 5)selectcust_id,cust_name from customersss where annual_revenue> 5000000 and cust_id in (select cust_id from shipmentsss where weight < 1 or destination = 'San Francisco'); Ans:-no rows selected 6)select truck_#,driver_name from trucksss where truck_# in (select truck_# from shipmentsss where cust_id in (select cust_id from customersss where annual_revenue>2000000) and destination in (select city_name from citysss where population > 1000000)); TRUCK_# DRIVER_NAME --------- -----------100 Jensen 102 Hrithik 101 Sasi 103 Jake Stinson
  • 3. 7)select distinct(destination) from shipmentsss where cust_id in ( select cust_id from customersss where annual_revenue>1500000); DESTINATION --------------London Baltimore Panama City San Francisco Rome St.Louis Los Angeles Manhattan Paris 9 rows selected. 8)select truck_#,driver_name from trucksss where truck_# in (select truck_# from shipmentsss where weight > 100); TRUCK_# DRIVER_NAME --------- -----------100 Jensen 102 Hrithik
  • 4. 103 Jake Stinson 9)selectcust_name,annual_revenue from customersss where cust_id in (select cust_id from shipmentsss where weight > 100); CUST_NAME ANNUAL_REVENUE -------------------- -------------Revathi 1000000 Richa 1800000 Rishi 1000000 Kalyan 4800000 10)selectcust_name,annual_revenue from customersss where cust_id in (select cust_id from shipmentsss where truck_# in (select truck_# from trucksss where driver_name = 'Jensen')); CUST_NAME ANNUAL_REVENUE -------------------- -------------Revathi 1000000 Kalyan 4800000 Rijesh 4000000 11)selectcust_id,cust_name from customersss where ( select count(distinct(truck_#)) from shipmentsss where shipmentsss.cust_id = customersss.cust_id) >= (select count(*) from truck);
  • 5. CUST_ID CUST_NAME --------- -------------------100 Revathi 103 Rijesh 104 Kalyan 12)selectcity_name from citysss where (select count (distinct ( cust_id)) from shipmentsss where destination = citysss.city_name) >= (select count (*) from customersss); Ans:no rows selected 13)selectdriver_name from trucksss where truck_# in (select truck_# from trucksss where (select count(distinct(destination)) from shipmentsss where shipmentsss.truck_# = trucksss.truck_#) >= (select count (*) from citysss)); Ans:- no rows selected 14)selectcust_id,cust_name from customersss where cust_type = 'manufacturer' or cust_id in (select cust_id from shipmentsss where destination = 'St. Louis'); CUST_ID CUST_NAME -------- -------------100 Revathi
  • 6. 15)selectcity_name from citysss where population > 1000000 and city_name in (select destination from shipmentsss where weight = 100 and cust_id = 311); Ans:- no rows selected 16)> select truck_# from trucksss where driver_name = 'Jake Stinson' and truck_# in (select truck_# from shipmentsss where destination <> 'Denver'); TRUCK_# ---------103 17)selectcust_id,cust_name from customersss where annual_revenue> 10000000 and cust_id in (select cust_id from shipmentsss where destination in (selectcity_name from city where population < 10000) and weight < 1); Ans:- no rows selected 18a)SQL> create view revenue_1 as select cust_id,cust_name from customerss where annual_revenue< 1000000; b)create view revenue_2 as select cust_id,cust_name from customersss where annual_revenue> 1000000 and annual_revenue< 5000000; c)> create view revenue_3 as select cust_id, cust_name from customersss where annual_revenue> 5000000;
  • 7. 19a)select * from revenue_3 where cust_id in (select cust_id from shipmentsss where destination = 'Los Angeles');

×