26 questions from CBSE board, sample and compartment papers (2024–2027), 1 to 4 marks, each with a model answer. Questions on writing SQL queries and predicting their output: WHERE conditions, BETWEEN, LIKE, IS NULL, ORDER BY, DISTINCT, aggregate functions and GROUP BY, plus some INSERT and UPDATE commands and MySQL data types.
Simple Queries in SQL· 4 Marks· Q31· 2024 Board Paper
Consider the tables Admin and Transport given below:
Table: Admin [S_id, S_name, Address, S_type]
S001 | Sandhya | Rohini | Day Boarder
S002 | Vedanshi | Rohtak | Day Scholar
S003 | Vibhu | Raj Nagar | NULL
S004 | Atharva | Rampur | Day Boarder
Table: Transport [S_id, Bus_no, Stop_name]
S002 | TSS10 | Sarai Kale Khan
S004 | TSS12 | Sainik Vihar
S005 | TSS10 | Kamla Nagar
Write SQL queries for the following:
(i) Display the student name and their stop name from the tables Admin and Transport.
(ii) Display the number of students whose S_type is not known.
(iii) Display all details of the students whose name starts with 'V'.
(iv) Display student id and address in alphabetical order of student name, from the table Admin.
Model answer
(i) SELECT A.S_name, T.Stop_name FROM Admin A, Transport T WHERE A.S_id = T.S_id;
(ii) SELECT COUNT(*) FROM Admin WHERE S_type IS NULL;
(iii) SELECT * FROM Admin WHERE S_name LIKE 'V%';
(iv) SELECT S_id, Address FROM Admin ORDER BY S_name ASC;
SELECT A.S_name, T.Stop_name FROM Admin A, Transport T WHERE A.S_id = T.S_id;
SELECT COUNT(*) FROM Admin WHERE S_type IS NULL;
SELECT * FROM Admin WHERE S_name LIKE 'V%';
SELECT S_id, Address FROM Admin ORDER BY S_name ASC;
Simple Queries in SQL· 1 Mark· Q14· 2025 Board Paper
Which aggregate function in SQL displays the number of values in the specified column ignoring the NULL values?
Simple Queries in SQL· 1 Mark· Q15· 2025 Board Paper
In MYSQL, which type of value should not be enclosed within quotation marks?
(A)DATE
(B)VARCHAR
(C)FLOAT
(D)CHAR
Model answer
FLOAT
Explanation: Numeric values (FLOAT, INT) are not enclosed in quotes.
Simple Queries in SQL· 4 Marks· Q32· 2025 Board Paper
Suman has created a table named WORKER with a set of records to maintain the data of the construction sites, which consists of WID, WNAME, WAGE, HOURS, TYPE, and SITEID. After creating the table, she entered data in it, which is as follows:
WID | WNAME | WAGE | HOURS | TYPE | SITEID
W01 | Ahmed J | 1500 | 200 | Unskilled | 103
W11 | Naveen S | 520 | 100 | Skilled | 101
W02 | Jacob B | 780 | 95 | Unskilled | 101
W15 | Nihal K | 560 | 110 | Semiskilled | NULL
W10 | Anju S | 1200 | 130 | Skilled | 103
(a) Based on the data given above, answer the following questions:
(i) Write the SQL statement to display the names and wages of those workers whose wages are between 800 and 1500.
(ii) Write the SQL statement to display the record of workers whose SITEID is not known.
(iii) Write the SQL statement to display WNAME, WAGE and HOURS of all those workers whose TYPE is 'Skilled'.
(iv) Write the SQL statement to change the WAGE to 1200 of the workers where the TYPE is "Semiskilled".
OR
(b) Considering the above given table WORKER, write the output on execution of the following SQL commands:
(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;
Model answer
(i) SELECT WNAME, WAGE FROM WORKER WHERE WAGE BETWEEN 800 AND 1500; (ii) SELECT * FROM WORKER WHERE SITEID IS NULL; (iii) SELECT WNAME, WAGE, HOURS FROM WORKER WHERE TYPE='Skilled'; (iv) UPDATE WORKER SET WAGE=1200 WHERE TYPE='Semiskilled';
Explanation: -
Simple Queries in SQL· 4 Marks· Q34· 2025 Board Paper
Assume that you are working in the IT Department of a Creative Art Gallery (CAG), which sells different forms of art creations like Paintings, Sculptures etc. The data of Art Creations and Artists are kept in tables Articles and Artists respectively. Following are few records from these two tables:
Table: Articles
Code | A_Code | Article | DOC | Price
PL001 | A0001 | Painting | 2018-10-19 | 20000
SC028 | A0004 | Sculpture | 2021-01-15 | 16000
QL005 | A0003 | Quilling | 2024-04-24 | 3000
Table: Artists
A_Code | Name | Phone | Email | DOB
A0001 | Roy | 595923 | r@CrAG.com | 1986-10-12
A0002 | Ghosh | 1122334 | ghosh@CrAG.com | 1972-02-05
A0003 | Gargi | 121212 | Gargi@CrAG.com | 1996-03-22
A0004 | Mustafa | 33333333 | Mf@CrAG.com | 2000-01-01
Note: The tables contain many more records than shown here. DOC is Date of Creation of an Article.
As an employee of CAG, you are required to write the SQL queries for the following:
(i) To display all the records from the Articles table in descending order of price.
(ii) To display the details of Articles which were created in the year 2020.
(iii) To display the structure of Artists table.
(iv) (a) To display the name of all artists whose Article is Painting through Equi Join.
OR
(b) To display the name of all Artists whose Article is 'Painting' through Natural Join.
Model answer
(i) SELECT * FROM Articles ORDER BY Price DESC; (ii) SELECT * FROM Articles WHERE DOC LIKE '2020%'; (iii) DESC Artists; (iv) SELECT Name FROM Artists A, Articles AR WHERE A.ACode = AR.ACode AND Article='Painting';
Explanation: -
Simple Queries in SQL· 1 Mark· Q14· 2026 Board Paper
What will be the output of the query?
SELECT MACHINE_ID, MACHINE_NAME FROM INVENTORY WHERE QUANTITY <= 100;
(A)All columns of INVENTORY table with quantity greater than 100
(B)ID and name of machines with quantity less than 100 from INVENTORY table
(C)All columns of INVENTORY table with quantity greater than or equal to 100
(D)ID and name of machines with quantity less than or equal to 100 from INVENTORY table.
Model answer
ID and name of machines with quantity less than or equal to 100 from INVENTORY table.
Explanation: The SELECT clause picks ID and Name. The WHERE clause uses <= (less than or equal to).
Simple Queries in SQL· 1 Mark· Q16· 2026 Board Paper
Which aggregate function in SQL returns the smallest value from a column in a table?
(A)MIN()
(B)SMALL()
(C)MAX()
(D)LOWER()
Model answer
MIN()
Explanation: MIN() is the SQL aggregate function used to find the minimum (smallest) value.
Simple Queries in SQL· 4 Marks· Q32· 2026 Board Paper
STOCK table queries: (a) (i) Type and max Price for each Type. (ii) Increase Price by 0.5 where Type is 'F'. (iii) Total value (Qty * Price). (iv) Details where Code starts with 'A'.
OR (b) Output of 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;
Model answer
(a) (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%';
(b) Output (i):
VOLUME | QTY | PRICE
0.5 | 300 | 38.00
0.5 | 250 | 36.50
1.0 | 50 | 52.00
Output (ii):
CODE | QTY
AF0.5 | 300
MF0.5 | 250
PT0.5 | 78
Output (iii):
F
T
D
Output (iv):
VOLUME | COUNT(*)
0.5 | 3
1.0 | 3
Explanation: Standard SQL applications involving aggregates, updates, distinct selection, grouping, and specific filter conditions.
Simple Queries in SQL· 1 Mark· Q14· 2025 Compartment Paper
Which of the following is not a valid relational operator used with WHERE clause in SQL?
(A)>
(B)<
(C)=>
(D)=
Model answer
=>
Explanation: The correct operator for 'greater than or equal to' is >=, not =>.
Simple Queries in SQL· 1 Mark· Q15· 2025 Compartment Paper
What is the default format of date in MySQL?
(A)DD-MM-YYYY
(B)MM-DD-YYYY
(C)YYYY-MM-DD
(D)YYYY-DD-MM
Model answer
YYYY-MM-DD
Explanation: MySQL standard format requires Year, then Month, then Day.
Simple Queries in SQL· 1 Mark· Q16· 2025 Compartment Paper
Ginni has created a table, SCORES in MySQL containing the following records:
Ranveer: 50, Sukesh: 35, Mirza: 10, John: 51, Murugan: 70.
Which of the following statements will give 10 as output?
(A)SELECT MAX(Score) FROM Scores;
(B)SELECT MIN(Score) FROM Scores;
(C)SELECT SUM(Score) FROM Scores;
(D)SELECT AVG(Score) FROM Scores;
Model answer
SELECT MIN(Score) FROM Scores;
Explanation: The MIN aggregate function finds the lowest value in the Score column, which is 10.
Simple Queries in SQL· 4 Marks· Q32· 2025 Compartment Paper
Write SQL queries for STAFF table:
(I) Display average salary of each department.
(II) Insert record ('S333', 'GURMEET', 15000, 'ADMIN', 'CLERK').
(III) Display unique designations.
(IV) Display details of staff whose name is of four letters.
OR (b) Predict output of queries.
Model answer
(I) SELECT DEPARTMENT, AVG(SALARY) FROM STAFF GROUP BY DEPARTMENT;
(II) INSERT INTO STAFF VALUES ('S333', 'GURMEET', 15000, 'ADMIN', 'CLERK');
(III) SELECT DISTINCT DESIGNATION FROM STAFF;
(IV) SELECT * FROM STAFF WHERE STAFF_NAME LIKE '____';
Explanation: Standard SQL statements using Aggregate Functions, Insert, Distinct, and Pattern Matching.
Simple Queries in SQL· 4 Marks· Q34· 2025 Compartment Paper
SQL Queries based on Work and Contractor tables:
(I) Display all records from Work in alphabetical order of W_Name.
(II) Display names of contractors where W_Amt > 15000.
(III) Display structure of Work table.
(IV) (a) Count total records in Work table OR (b) Delete contractors where Phone is NULL.
Model answer
(I) SELECT * FROM Work ORDER BY W_Name;
(II) SELECT C_Name FROM Work W, Contractor C WHERE W.C_ID = C.C_ID AND W_Amt > 15000;
(III) DESC Work;
(IV)(a) SELECT COUNT(*) FROM Work; OR (IV)(b) DELETE FROM Contractor WHERE Phone IS NULL;
Explanation: Standard SQL commands involving Joins, Description, Aggregate functions, and Deletion based on conditions.
Simple Queries in SQL· 1 Mark· Q2· 2024 Sample Paper
In a table in MYSQL database, an attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of datatype char(20) has value “Meenakshi”. How many characters are occupied by attribute A and attribute B?
(A)a. 20,6
(B)b. 6,20
(C)c. 9,6
(D)d. 6,9
Model answer
Option b
6,20
Explanation: VARCHAR is variable-length and occupies only the length of the string ('Keshav' = 6 characters), whereas CHAR is fixed-length and occupies the defined width (20 characters).
Simple Queries in SQL· 3 Marks· Q27· 2024 Sample Paper
Consider the table CLUB given below and write the output of the SQL queries that follow.
Table: CLUB
CID | CNAME | AGE | GENDER | SPORTS | PAY | DOAPP
5246 | AMRITA | 35 | FEMALE | CHESS | 900 | 2006-03-27
4687 | SHYAM | 37 | MALE | CRICKET | 1300 | 2004-04-15
1245 | MEENA | 23 | FEMALE | VOLLEYBALL | 1000 | 2007-06-18
1622 | AMRIT | 28 | MALE | KARATE | 1000 | 2007-09-05
1256 | AMINA | 36 | FEMALE | CHESS | 1100 | 2003-08-15
1720 | MANJU | 33 | FEMALE | KARATE | 1250 | 2004-04-10
2321 | VIRAT | 35 | MALE | CRICKET | 1050 | 2005-04-30
(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;
(ii) SELECT CNAME, SPORTS FROM CLUB WHERE DOAPP<"2006-04-30" AND CNAME LIKE "%NA";
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE GENDER = "MALE" AND PAY BETWEEN 1000 AND 1200;
Model answer
(i)
COUNT(DISTINCT SPORTS)
4
(ii)
CNAME SPORTS
AMINA CHESS
(iii)
CNAME AGE PAY
AMRIT 28 1000
VIRAT 35 1050
Simple Queries in SQL· 1 Mark· Q14· 2025 Sample Paper
What will be the output of the query?
SELECT * FROM products WHERE product_name LIKE
'App%';
(A)Details of all products whose names start with 'App'
(B)Details of all products whose names end with 'App'
(C)Names of all products whose names start with 'App'
(D)Names of all products whose names end with 'App'
Model answer
(A) Details of all products whose names start with 'App'
Explanation: The % wildcard matches any sequence of characters.
Simple Queries in SQL· 1 Mark· Q15· 2025 Sample Paper
In which datatype the value stored is padded with spaces to fit the specified length.
(A)DATE
(B)VARCHAR
(C)FLOAT
(D)CHAR
Model answer
(D) CHAR
Explanation: CHAR is fixed length: a shorter value is padded with spaces up to the declared size. VARCHAR stores only the characters given.
Simple Queries in SQL· 1 Mark· Q16· 2025 Sample Paper
Which aggregate function can be used to find the cardinality of a table?
(A)sum()
(B)count()
(C)avg()
(D)max()
Model answer
(B) count()
Explanation: Cardinality is the number of rows, and COUNT(*) returns the number of rows.
Simple Queries in SQL· 4 Marks· Q32· 2025 Sample Paper
Consider the table ORDERS as given below
O_Id | C_Name | Product | Quantity | Price
1001 | Jitendra | Laptop | 1 | 12000
1002 | Mustafa | Smartphone | 2 | 10000
1003 | Dhwani | Headphone | 1 | 1500
Note: The table contains many more records than shown here.
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with total Quantity less than 5.
(II) To display the orders table sorted by total price in descending order.
(III) To display the distinct customer names from the Orders table.
(IV) Display the sum of Price of all the orders for which the quantity is null.
OR
B) Write the output
(I) Select c_name, sum(quantity) as total_quantity from orders group by c_name;
(II) Select * from orders where product like '%phone%';
(III) Select o_id, c_name, product, quantity, price from orders where price between 1500 and 12000;
(IV) Select max(price) from orders;
Model answer
A)
(I) SELECT Product, SUM(Quantity) FROM ORDERS GROUP BY Product HAVING SUM(Quantity) >= 5;
(II) SELECT * FROM ORDERS ORDER BY Price * Quantity DESC;
(III) SELECT DISTINCT C_Name FROM ORDERS;
(IV) SELECT SUM(Price) FROM ORDERS WHERE Quantity IS NULL;
OR
B) (for the rows shown)
(I) Jitendra 1, Mustafa 2, Dhwani 1
(II) 1002 Mustafa Smartphone 2 10000 and 1003 Dhwani Headphone 1 1500
(III) All three rows (1001, 1002, 1003)
(IV) 12000
Simple Queries in SQL· 4 Marks· Q32· 2026 Sample Paper
Consider the table SALES as given below:
sales_id | customer_name | product | quantity_sold | price
S001 | John Doe | Laptop | 5 | 50000
S002 | Jane Smith | Smartphone | 10 | 30000
S003 | Michael Lee | Tablet | 3 | 15000
S004 | Sarah Brown | Headphones | 7 | 2000
S005 | Emily Davis | Smartwatch | 8 | 8000
S006 | David | Smartwatch | 3 | 16000
S007 | Mark | Tablet | 5 | 34000
A. Write the following queries:
I. To display the total quantity sold for each product whose total quantity sold exceeds 12.
II. To display the records of SALES table sorted by Product name in descending order.
III. To display the distinct Product names from the SALES table.
IV. To display the records of customers whose names end with the letter 'e'.
OR
B. Predict the output of the following:
I. SELECT * FROM Sales where product='Tablet';
II. SELECT sales_id, customer_name FROM Sales WHERE product LIKE 'S%';
III. SELECT COUNT(*) FROM Sales WHERE product in ('Laptop', 'Tablet');
IV. SELECT AVG(price) FROM Sales where product='Tablet';
Model answer
I. SELECT Product, SUM(quantity_sold) FROM SALES GROUP BY Product HAVING SUM(quantity_sold)>12; II. SELECT * FROM SALES ORDER BY Product DESC; III. SELECT DISTINCT Product FROM SALES; IV. SELECT * FROM SALES WHERE Customer_Name LIKE '%e';
Explanation: .
Simple Queries in SQL· 1 Mark· Q9· 2027 Sample Paper
Which MySQL query will display all employees whose salaries are between 90,000 and 100,000 (including limits)?
(A)SELECT * FROM Employees WHERE salary > 90000 AND salary < 100000;
(B)SELECT * FROM Employees WHERE salary IN (90000, 100000);
(C)SELECT * FROM Employees WHERE salary BETWEEN 90000 AND 100000;
(D)SELECT * FROM Employees WHERE salary = 90000 OR salary = 100000;
Model answer
c) SELECT * FROM Employees WHERE salary BETWEEN 90000 AND 100000;
Simple Queries in SQL· 1 Mark· Q21· 2027 Sample Paper
Assertion (A): The MySQL query SELECT Student_Name FROM Student WHERE Guardian_Phone IS NULL; displays the names of students whose guardian phone number is not recorded.
Reason (R): In MySQL, you can also use = to check for NULL values; it is equivalent to IS NULL to identify columns with no value.
(A)Both A and R are True and R is the correct explanation for A.
(B)Both A and R are True and R is not the correct explanation for A.
(C)A is True but R is False.
(D)A is False but R is True.
Model answer
c) A is true, but R is false
Simple Queries in SQL· 4 Marks· Q32· 2027 Sample Paper
Consider the table TECH_EVENT_REG as given below:
A. Write the following queries:
I. To display the number of participants in each event where the number of participants is greater than 1.
II. To display the distinct event names available in the Tech Event.
III. To display details of participants whose names contain the letters ‘an’.
IV. To display all records of TECH_EVENT_REG sorted by participant_name in descending order.
OR
B. Predict the output of the following:
I. Select participant_name, event_name from tech_event_reg where grade = 11;
II. Select event_name, count(*) from tech_event_reg group by event_name;
III. Select participant_name from tech_event_reg where event_name like '%challenge';
IV. Select max(reg_fee) from tech_event_reg where grade in (9, 10);
Model answer
A.
I. select event_name, count(*) as total_participants from tech_event_reg group by event_name having count(*) > 1;
II. select distinct event_name from tech_event_reg;
III. select * from tech_event_reg where participant_name like '%an%';
IV. select * from tech_event_reg order by participant_name desc;
OR
B.
I.
participant_name | event_name
Aarav | Hackathon
Navya | Hackathon
II.
event_name | COUNT(*)
Hackathon | 2
RoboRace | 2
WebDev Challenge | 1
CodeSprint | 1
III.
participant_name
Krish
IV.
MAX(reg_fee)
150
select event_name, count(*) as total_participants from tech_event_reg group by event_name having count(*) > 1;
select distinct event_name from tech_event_reg;
select * from tech_event_reg where participant_name like '%an%';
select * from tech_event_reg order by participant_name desc;