CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Structure Query Language Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE STRUCTURED QUERY LANGUAGE Outside Delhi 2007: 5.b) Consider the following tables Consignor and Consignee. Write SQL command for the statements(i)to(iv) And give outputs for the SQL quries (v) to ( viii). 6 TABLE : CONSIGNOR
TABLE : CONSIGNEE
(i) To display the names of all consignors from Mumbai. Ans: Select CnorName from Consignor where city=”Mumbai”; (ii) To display the cneeID, cnorName, cnorAddress, CneeName, CneeAddress for
every Consignee. Ans: Select CneeId, CnorName, CnorAddress, CneeName, CneeAddress from Consignor,Consignee where Consignor.CnorId=Consignee.CnorId; (iii) To display the consignee details in ascending order of CneeName. Ans: Select * from Consignee Orderby CneeName Asc; (iv) To display number of consignors from each city. Ans: Select city, count(*) from Consignors group by city; (v) SELECT DISTINCT City FROM CONSIGNEE; Ans:
(vi) SELECT A.CnorName A, B.CneeName B FROM Consignor A, Consignee B WHERE A.CnorID=B.CnorID AND B.CneeCity=’Mumbai’; (vii) SELECT CneeName,CneeAddress FROM Consignee WHERE CneeCity Not IN (‘Mumbai’, ‘Kolkata’); Ans: (viii) SELECT CneeID, CneeName FROM Consignee WHERE CnorID = ‘MU15’ OR CnorID = ‘ND01’;
Ans: CneeID
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] ) |
|