CBSE 2026 · Central · Set 4 · Q32 · 4 marks
Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his shop. After creating the table, he entered the data and the table looked as follows: Code Type Volume Qty Price AF0.5 F $\displaystyle 0.5$ $\displaystyle 300$ $\displaystyle 38.00$ MF0.5 F $\displaystyle 0.5$ $\displaystyle 250$ $\displaystyle 36.50$ MT1.0 T $\displaystyle 1.0$ $\displaystyle 150$ $\displaystyle 64.00$ AT1.0 T $\displaystyle 1.0$ $\displaystyle 100$ $\displaystyle 66.00$ PD1.0 D $\displaystyle 1.0$ $\displaystyle 50$ $\displaystyle 52.00$ PT0.5 T $\displaystyle 0.5$ $\displaystyle 78$ $\displaystyle 30.00$
(a)Based on the data given above, write the SQL queries for the following tasks :(i)To display Type and the maximum Price for each Type of milk.(ii)For each record, increase the Price by $\displaystyle 0.5$ where Type is 'F'.(iii)To display the total value of the stock (total of Qty × Price).(iv)To display the details of all records where Code starts with 'A'.(b)Considering the table STOCK as given above, write the output on execution of the following queries :(i)SELECT Volume, Qty, Price FROM STOCK WHERE Type IN ('F','D');(ii)SELECT Code, Qty FROM STOCK WHERE Price BETWEEN $\displaystyle 30$ AND $\displaystyle 50$;(iii)SELECT DISTINCT Type FROM STOCK;(iv)SELECT Volume, count(*) FROM STOCK GROUP BY Volume;
Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his shop. After creating the table, he entered the data and the table looked as follows:
| Code | Type | Volume | Qty | Price |
| AF0.5 | F | $\displaystyle 0.5$ | $\displaystyle 300$ | $\displaystyle 38.00$ |
| MF0.5 | F | $\displaystyle 0.5$ | $\displaystyle 250$ | $\displaystyle 36.50$ |
| MT1.0 | T | $\displaystyle 1.0$ | $\displaystyle 150$ | $\displaystyle 64.00$ |
| AT1.0 | T | $\displaystyle 1.0$ | $\displaystyle 100$ | $\displaystyle 66.00$ |
| PD1.0 | D | $\displaystyle 1.0$ | $\displaystyle 50$ | $\displaystyle 52.00$ |
| PT0.5 | T | $\displaystyle 0.5$ | $\displaystyle 78$ | $\displaystyle 30.00$ |
(a)
Based on the data given above, write the SQL queries for the following tasks :
(i)
To display Type and the maximum Price for each Type of milk.
(ii)
For each record, increase the Price by $\displaystyle 0.5$ where Type is 'F'.
(iii)
To display the total value of the stock (total of Qty × Price).
(iv)
To display the details of all records where Code starts with 'A'.
(b)
Considering the table STOCK as given above, write the output on execution of the following queries :
(i)
SELECT Volume, Qty, Price FROM STOCK WHERE Type IN ('F','D');
(ii)
SELECT Code, Qty FROM STOCK WHERE Price BETWEEN $\displaystyle 30$ AND $\displaystyle 50$;
(iii)
SELECT DISTINCT Type FROM STOCK;
(iv)
SELECT Volume, count(*) FROM STOCK GROUP BY Volume;
Marking-scheme solution
(i)
SELECT TYPE, MAX(PRICE) FROM STOCK
GROUP BY TYPE;(ii)
UPDATE STOCK
SET PRICE=PRICE+0.5 WHERE TYPE='F';(iii)
SELECT SUM(QTY*PRICE) FROM STOCK;(iv)
SELECT * FROM STOCK
WHERE CODE LIKE 'A%'; OR WHERE CODE LIKE 'A_ _ _ _'(i)
SELECT Volume, Qty, Price FROM STOCK
WHERE Type IN ('F','D');VOLUME QTY PRICE
0.5 300 38.00
0.5 250 36.50
1.0 50 52.00(ii)
SELECT Code, Qty FROM STOCK
WHERE Price BETWEEN 30 AND 50;CODE QTY
AF0.5 300
MF0.5 250
PT0.5 78(iii)
SELECT DISTINCT Type FROM STOCK;DISTINCT TYPE
F
T
D(iv)
SELECT Volume, count(*) FROM STOCK
GROUP BY Volume;VOLUME COUNT(*)
0.5 3
1.0 3Structured Query LanguageGROUP BY and HAVINGApplycase_study
More from Structured Query Language
- Ms. Zoya is a Production Manager in a factory which packages mineral water. She decides to create a table in…2026
- Assume that you are the Manager of the Loans department of a Finance House. To keep track of the loans you…2026
- Which aggregate function in SQL returns the smallest value from a column in a table?2026
- What will be the output of the query? SELECT MACHINE ID, MACHINE NAME FROM INVENTORY WHERE QUANTITY <= 100;2026
CBSE Class 12 Computer Science past-paper question from the 2026board exam, with the answer as CBSE’s own marking scheme gives it. Where our answers come from.