SQL: Aggregates, Grouping and Joins Class 12 PYQs 2024–2026 with Solutions | CBSE Computer Science Skip to content
Smart Notes for Every Exam · instant PDF download after payment +91 92520 37565
Class 12 · Computer Science · Chapter 13

SQL: Aggregates, Grouping and Joins: Class 12 PYQs 2024–2026 with solutions

All 11 CBSE board questions asked from SQL: Aggregates, Grouping and Joins in 3 board papers, with the year, set and marks of each. 7 are solved free below. The Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE) has every solution, all chapters and 3 full board papers.

Cover of Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE)
Class 12 Computer Science PYQ book: every chapter + 3 board papers, all solved
₹99₹14934% off
Free sample

SQL: Aggregates, Grouping and Joins: board weightage

Board weightage 2024–2026

Year202420252026
Questions443
Marks9109

Most asked topics

Aggregate functions4
GROUP BY and HAVING3
Joins3
SQL with two tables1

11 questions from 3 papers. Repeated questions are shown once with every year they were asked.

Jump to: 1 mark3 marks4 marks

1 mark: MCQ and Assertion–Reason

Q1 · CBSE 2026 · 91 · Q161 mark

Which aggregate function returns the smallest value from a column? (A) MIN() (B) MAX() (C) SMALL() (D) LOWER()

Solution

(A) MIN().

Q2 · CBSE 2025 · 91 · Q141 mark

Which aggregate function displays the number of values in a column ignoring NULL values? (A) len() (B) count() (C) number() (D) num()

Solution

(B) count(), i.e. COUNT(column).

Q3 · CBSE 2025 · 91 · Q161 mark

True or False: If table A has 6 rows and 3 columns and table B has 5 rows and 2 columns, the Cartesian product of A and B will have 30 rows and 5 columns.

Solution

True: rows 6 × 5 = 30; columns 3 + 2 = 5.

Q4 · CBSE 2024 · 91 · Q51 mark

The aggregate function which will display the cardinality of a table is ____. (a) sum() (b) count(*) (c) avg() (d) sum(*)

Full step-by-step solution is in the PYQ book (₹99).
Q5 · CBSE 2024 · 91 · Q35(A)(i)1 mark

(A)(i) Define Cartesian Product with respect to RDBMS.

Full step-by-step solution is in the PYQ book (₹99).

3 marks: short answer

Q6 · CBSE 2024 · 91 · Q273 marks

Table ORDERS: (1001 RICE 23 120 2023-09-10), (1002 PULSES 13 120 2023-10-18), (1003 RICE 25 110 2023-11-17), (1004 WHEAT 28 65 2023-12-25), (1005 PULSES 16 110 2024-01-15), (1006 WHEAT 27 55 2024-04-15), (1007 WHEAT 25 60 2024-04-30) [ORDNO ITEM QTY RATE ORDATE]. Output: (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;

Solution

(i) RICE 23 + 25; PULSES 13 + 16; WHEAT 28 + 27 + 25.

RICE    48
PULSES 29
WHEAT 80

(ii) Orders in Nov–Dec 2023: 1003, 1004.

RICE   25
WHEAT 28

(iii) WHEAT rows 1004 (65), 1006 (55 ✗), 1007 (60).

1004  2023-12-25
1007 2024-04-30

4 marks: SQL / case-based

Q7 · CBSE 2026 · 91 · Q324 marks

Table STOCK (13.1). (a) Write queries: (i) Type and maximum Price for each Type; (ii) increase Price by 0.5 where Type is 'F'; (iii) total value of stock (total of Qty × Price); (iv) details of records where Code starts with 'A'.
OR (b) OR, outputs: (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;

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; -- 41665.00
(iv) SELECT * FROM STOCK WHERE Code LIKE 'A%'; -- AF0.5, AT1.0

OR
(i)   0.5  300  38.00
0.5 250 36.50
1.0 50 52.00
(ii) AF0.5 300
MF0.5 250
PT0.5 78
(iii) F
T
D
(iv) 0.5 3
1.0 3
(ii) BETWEEN is inclusive, so PT0.5 at exactly 30.00 is included.

Q8 · CBSE 2026 · 91 · Q344 marks

CUSTOMERS and LOANS (13.4). Write queries for: (i) number of LOANS records with RoI above 7.0; (ii) names of customers whose L_Amt is above 1000000; (iii) C_ID, C_Name and Terms of records with L_Date after 31 December 2024; (iv)(a) details of all loans in descending order of RoI, OR (b) C_ID and average term for each C_ID from LOANS.

Solution

(i)   SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0;            -- 3
(ii) SELECT C_Name FROM CUSTOMERS, LOANS
WHERE CUSTOMERS.C_ID = LOANS.C_ID AND L_Amt > 1000000; -- Abdul
(iii) SELECT C.C_ID, C_Name, Terms FROM CUSTOMERS C, LOANS L
WHERE C.C_ID = L.C_ID AND L_Date > '2024-12-31';
(iv)(a) SELECT * FROM LOANS ORDER BY RoI DESC;
(iv)(b) SELECT C_ID, AVG(Terms) FROM LOANS GROUP BY C_ID;
(iii) gives 00003 David Xavier 60; 00001 Raj Malhotra 48; 00003 David Xavier 36; 00004 Damini Iyer 60. Write C.C_ID (not just C_ID) in a join, or MySQL reports an ambiguous column.

Q9 · CBSE 2025 · 91 · Q32(B)4 marks

(b) Table WORKER (Chapter 12): outputs of (i) SELECT WNAME, WAGE*HOURS FROM WORKER WHERE SITEID = 103; (ii) SELECT COUNT(DISTINCT TYPE) FROM WORKER; (iii) SELECT MAX(WAGE), MIN(WAGE), TYPE FROM WORKER GROUP BY TYPE; (iv) SELECT WNAME, SITEID FROM WORKER WHERE TYPE="Unskilled" ORDER BY HOURS;

Solution

(i) Site 103: Ahmed J 1500 × 200, Anju S 1200 × 130.

Ahmed J  300000
Anju S 156000

(ii) Types: Unskilled, Skilled, Semiskilled.

3

(iii)

1500  780  Unskilled
1200 520 Skilled
560 560 Semiskilled

(iv) Unskilled: Jacob B (95 h), Ahmed J (200 h).

Jacob B  101
Ahmed J 103

Q10 · CBSE 2025 · 91 · Q344 marks

Creative Art Gallery: Articles(Code, A_Code, Article, DOC, Price) and Artists(A_Code, Name, Phone, Email, DOB). Write queries: (i) all records of Articles in descending order of price; (ii) Articles created in the year 2020; (iii) structure of Artists; (iv)(a) names of all Artists whose Article is Painting through Equi Join, OR (b) through Natural Join.

Full step-by-step solution is in the PYQ book (₹99).
Q11 · CBSE 2024 · 91 · Q314 marks

Tables Admin(S_id, S_name, Address, S_type) and Transport(S_id, Bus_no, Stop_name). Write SQL: (i) student name and stop name from both tables; (ii) number of students whose S_type is not known; (iii) all details of students whose name starts with 'V'; (iv) student id and address in alphabetical order of student name.

Full step-by-step solution is in the PYQ book (₹99).

Get every solution for all chapters

  • Every board question of every chapter, each fully solved the way the board gives marks
  • 3 complete board papers, each followed by its solutions
  • Weightage and most-asked topics for every chapter
  • Instant PDF download, colour and black & white print copies
See real pages (free sample)

Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →

What you get in the pack

All chapters in this pack

  1. PYQ Ch 1 Python Revision Tour
  2. PYQ Ch 2 Functions
  3. PYQ Ch 3 Exception Handling
  4. PYQ Ch 4 Text Files
  5. PYQ Ch 5 Binary Files
  6. PYQ Ch 6 CSV Files
  7. PYQ Ch 7 Stack
  8. PYQ Ch 8 Computer Networks I: Evolution and Data Communication
  9. PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
  10. PYQ Ch 10 Network Protocols and Web Services
  11. PYQ Ch 11 Database Concepts
  12. PYQ Ch 12 SQL: DDL, DML and Queries
  13. PYQ Ch 13 SQL: Aggregates, Grouping and Joins
  14. PYQ Ch 14 Interface of Python with MySQL
  15. Board Paper 2026 Set 91 with Solutions
  16. Board Paper 2025 Set 91 with Solutions
  17. Board Paper 2024 Set 91 with Solutions
← PYQ Ch 12 SQL: DDL, DML and Queries PYQ Ch 14 Interface of Python with MySQL →

Prices shown in Indian rupees. Show prices in: ₹ INR · US$ USD