Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 35 of 58
Marks: +1, -0
Consider the table ORDERS given below and write the output of the SQL queries that follow :
ORDNOITEMQTYRATEORDATE
1001RICE231202023-09-10
1002PULSES131202023-10-18
1003RICE251102023-11-17
1004WHEAT28652023-12-25
1005PULSES161102024-01-15
1006WHEAT27552024-04-15
1007WHEAT25602024-04-30
(i) SELECT ITEM, SUM(QTY) FROM ORDERS GROUP BY ITEM;
(ii) SELECT ITEM, QTY FROM ORDERS WHERE ORDATE BETWEEN '2023-11-01' AND '2023-12-31';
(iii) SELECT ORDNO, ORDATE FROM ORDERS WHERE ITEM = 'WHEAT' AND RATE>=60;
[CBSE 2024 Set 4]
Solution:  
(i) Rows are grouped by ITEM and QTY is added in each group:
ITEMSUM(QTY)
RICE48
PULSES29
WHEAT80
(RICE 23 + 25, PULSES 13 + 16, WHEAT 28 + 27 + 25)
(ii) Orders dated from 1 Nov 2023 to 31 Dec 2023 (both included):
ITEMQTY
RICE25
WHEAT28
(iii) WHEAT orders with RATE 60 or more (1006 has rate 55, so it is left out):
ORDNOORDATE
10042023-12-25
10072024-04-30
© examsnet.com
Advertisements
Go to Question: