Skip to content
Question 68 of 95

Q.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 0.5 300 38.00 MF0.5 F 0.5 250 36.50 MT1.0 T 1.0 150 64.00 AT1.0 T 1.0 100 66.00 PD1.0 D 1.0 50 52.00 PT0.5 T 0.5 78 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 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'.
(OR)
(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 30 AND 50;
(iii) SELECT DISTINCT Type FROM STOCK;
(iv) SELECT Volume, count(*) FROM STOCK GROUP BY Volume;
Puducherry TnboardCBSE Class XII Board 2026Subjective· 4mImportance★★★★★
72% · 68/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): write SQL using GROUP BY+MAX, UPDATE, SUM(Qty*Price)=41665, and LIKE 'A%'. Part (b): predict outputs for IN, BETWEEN, DISTINCT and GROUP BY count queries.

The STOCK table:

CodeTypeVolumeQtyPrice
AF0.5F0.530038.00
MF0.5F0.525036.50
MT1.0T1.015064.00
AT1.0T1.010066.00
PD1.0D1.05052.00
PT0.5T0.57830.00

Part (a)

(i) Group by Type and take the maximum Price of each group.

SELECT Type, MAX(Price) FROM STOCK GROUP BY Type;

Expected output:

F  38.00
T  66.00
D  52.00

(ii) Modify rows with UPDATE, restricted to Type 'F' by the WHERE clause.

UPDATE STOCK SET Price = Price + 0.5 WHERE Type = 'F';

This raises AF0.5 to 38.50 and MF0.5 to 37.00.

(iii) Multiply Qty by Price per row and total with SUM.

SELECT SUM(Qty * Price) AS TotalValue FROM STOCK;

Row values: 30038=11400, 25036.50=9125, 15064=9600, 10066=6600, 5052=2600, 7830=2340. Sum:

41665

(iv) Pattern-match with LIKE; 'A%' means "starts with A".

SELECT * FROM STOCK WHERE Code LIKE 'A%';

Expected output (AF0.5 and AT1.0):

AF0.5  F  0.5  300  38.00
AT1.0  T  1.0  100  66.00 …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.