★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
CBSE Class 12 · Computer Science, code 083 · Unit 3, 20 marks
Reading SQL is easy. Predicting what a query returns when a fee is NULL, or when two tables share one column too many, is where marks are lost. These 50 class 12 computer science SQL questions follow the 083 syllabus from keys to natural join, on two small tables you can hold in your head. Write your answer, then open ours and see exactly what MySQL gave back.
Live one to one · 50 original questions · every result from a real server · any day, your hour
Start here
The questions below test SQL. These courses teach it: alone, as part of the whole 083 syllabus, or after the Python it connects to.

SQL / Start to apps
Begins at the first SELECT and reaches joins, table design and apps. Past the syllabus in places, and the quickest route if queries feel like guesswork.
Open the course →
083 / Whole paper
SQL taught alongside Python, files and networks for CBSE students, with the report file's query sets built as you go.
Open the course →
Python / The other 40
For a student whose SQL is sound but whose Python is not. Programming is 40 of the 70 theory marks.
Open the course →Ans. The short version
Class 12 computer science SQL questions in CBSE 083 cover keys and constraints, DDL and DML commands, SELECT with WHERE, LIKE, BETWEEN, IN and NULL, aggregate functions, GROUP BY with HAVING, and three joins: cartesian product, equi-join and natural join. Database Management is 20 of the 70 theory marks in 2026-27, and the lab test adds 4 marks for SQL queries. This page has 50 original questions on two tables, with real MySQL output. Modern Age Coders teaches SQL live, personalised one to one at your timing, and a priority demo gives you a full class to try first.
Start here. Two tables, 20 marks
In the CBSE sample paper for 2026-27, the database unit fills six 1-mark questions, one 2-mark question and three 4-mark questions. One of those three is Python with MySQL; the rest is the SQL and relational theory on this page.
| Sample paper question | What it wants | Marks |
|---|---|---|
| 4, 9, 13, 15, 19, 21 | Keys, domain, degree and cardinality, one query or command to choose, NULL | 6 |
| 27 | Two commands, or a difference with examples | 2 |
| 32 | One table: four queries to write, or four outputs | 4 |
| 34 | Two tables: four queries, joins among them | 4 |
| 35 | A Python-MySQL program | 4 |
In 32 and 34 the marking scheme gives one mark for each correct query or output. There is no partial credit printed, so a missing condition can cost the full mark.
PET holds the animals. VISIT holds each trip to a vet. One pet may have several visits or none. Two weights were never taken, and one fee was never charged: those NULLs are there on purpose.
Keep both tables open beside you. Every query from Question 8 on was run on MySQL 26, and an older version in your lab may word an error slightly differently.
| PID | PName | Species | AgeM | Weight | Arrived |
|---|---|---|---|---|---|
| P01 | Biscuit | Dog | 14 | 11.5 | 2026-08-03 |
| P02 | Mishti | Cat | 8 | 3.2 | 2026-08-19 |
| P03 | Rocket | Dog | 30 | 18.4 | 2026-09-02 |
| P04 | Kaju | Rabbit | 6 | 1.8 | 2026-09-02 |
| P05 | Simba | Cat | 26 | NULL | 2026-10-11 |
| P06 | Bhalu | Dog | 9 | NULL | 2026-10-20 |
| P07 | Pihu | Cat | 5 | 2.4 | 2026-11-05 |
| P08 | Momo | Rabbit | 11 | 2.1 | 2026-11-05 |
AgeM is the age in months.
| VNo | PID | Vet | Reason | Fee | VDate |
|---|---|---|---|---|---|
| 101 | P01 | Dr Sen | Vaccine | 400 | 2026-08-10 |
| 102 | P03 | Dr Roy | Injury | 1500 | 2026-09-03 |
| 103 | P02 | Dr Sen | Vaccine | 400 | 2026-09-12 |
| 104 | P05 | Dr Roy | Checkup | 300 | 2026-10-12 |
| 105 | P01 | Dr Sen | Checkup | 300 | 2026-10-30 |
| 106 | P03 | Dr Roy | Injury | 900 | 2026-11-06 |
| 107 | P07 | Dr Iyer | Vaccine | NULL | 2026-11-09 |
Notes first, then commands
DDL commands build and change the table. DML commands work on the rows inside it. Anything not in this list, such as subqueries, views, triggers or outer joins, is outside the 083 syllabus for 2026-27.
| Command or clause | Kind | What it does | Shape to remember |
|---|---|---|---|
| CREATE DATABASE, USE, DROP DATABASE | DDL (USE only selects) | Make, open, remove a database | CREATE DATABASE shelter; |
| SHOW DATABASES, SHOW TABLES, DESCRIBE | Look only | List databases, list tables, show columns | DESCRIBE PET; |
| CREATE TABLE | DDL | Columns, types, constraints | PName VARCHAR(15) NOT NULL |
| ALTER TABLE | DDL | Add or remove a column or the primary key | ALTER TABLE PET ADD Tag CHAR(6); |
| DROP TABLE | DDL | Remove rows and structure | DROP TABLE PET; |
| INSERT | DML | Add rows | INSERT INTO PET VALUES (...); |
| UPDATE | DML | Change values in existing rows | UPDATE PET SET ... WHERE ...; |
| DELETE | DML | Remove rows, keep the table | DELETE FROM PET WHERE ...; |
| SELECT, DISTINCT, alias | DML | Choose columns, drop repeated rows, rename a heading | SELECT AgeM / 12 AS Years |
| WHERE with IN, BETWEEN, LIKE, IS NULL | Clause | Keep some rows | LIKE '_i%' |
| GROUP BY, HAVING | Clauses | Make groups, keep some groups | HAVING COUNT(*) > 2 |
| ORDER BY | Clause | Sort the result | ORDER BY Species, AgeM DESC |
| MAX, MIN, SUM, AVG, COUNT | Aggregate | One value from many rows | AVG(Fee) |
Data types: CHAR(n) has a fixed length, VARCHAR(n) holds up to n characters, then INT, FLOAT and DATE written as '2026-11-05'. Constraints: NOT NULL, UNIQUE, PRIMARY KEY.
CREATE DATABASE shelter; USE shelter;
CREATE TABLE PET(
PID CHAR(3) PRIMARY KEY,
PName VARCHAR(15) NOT NULL,
Species VARCHAR(10),
AgeM INT,
Weight FLOAT,
Arrived DATE);DESCRIBE VISIT; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | VNo | int | NO | PRI | NULL | | | PID | char(3) | NO | | NULL | | | Vet | varchar(15) | YES | | NULL | | | Reason | varchar(10) | YES | | NULL | | | Fee | int | YES | | NULL | | | VDate | date | YES | | NULL | | +--------+-------------+------+-----+---------+-------+
VNo says NO under Null although NOT NULL was never typed for it: a primary key brings that rule along.
ALTER TABLE PET ADD Tag CHAR(6); Query OK, 0 rows affected Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE PET MODIFY Tag VARCHAR(10); Query OK, 8 rows affected Records: 8 Duplicates: 0 Warnings: 0 ALTER TABLE PET DROP COLUMN Tag; Query OK, 0 rows affected Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE VISIT DROP PRIMARY KEY; Query OK, 7 rows affected Records: 7 Duplicates: 0 Warnings: 0 ALTER TABLE VISIT ADD PRIMARY KEY (VNo); Query OK, 0 rows affected Records: 0 Duplicates: 0 Warnings: 0
Dropping takes no column name, since a table has only one primary key. Adding needs it in brackets.
INSERT INTO PET VALUES
('P03', 'Tara', 'Dog', 7, 6.5, '2026-11-12');
ERROR 1062 (23000): Duplicate entry 'P03' for key 'pet.PRIMARY'
INSERT INTO PET VALUES
('P09', NULL, 'Dog', 7, 6.5, '2026-11-12');
ERROR 1048 (23000): Column 'PName' cannot be nullNeither row is stored.
INSERT INTO PET (PID, PName, Species)
VALUES ('P09', 'Tara', 'Dog');
Query OK, 1 row affected
UPDATE PET SET AgeM = 7, Arrived = '2026-11-12'
WHERE PID = 'P09';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM PET WHERE PID = 'P09';
+-----+-------+---------+------+--------+------------+
| PID | PName | Species | AgeM | Weight | Arrived |
+-----+-------+---------+------+--------+------------+
| P09 | Tara | Dog | 7 | NULL | 2026-11-12 |
+-----+-------+---------+------+--------+------------+Columns left out of the list become NULL. Weight still is.
DELETE FROM PET WHERE PID = 'P09'; Query OK, 1 row affected DELETE FROM PET WHERE PID = 'P55'; Query OK, 0 rows affected
No error, only 0 rows affected. And without WHERE, every row goes.
One table, rows and columns
WHERE keeps a row only when its condition is true for that row. False drops it, and so does unknown, which is what NULL produces.
SELECT PName, AgeM / 12 AS Years FROM PET WHERE Species = 'Dog'; +---------+--------+ | PName | Years | +---------+--------+ | Biscuit | 1.1667 | | Rocket | 2.5000 | | Bhalu | 0.7500 | +---------+--------+
Division with / gives decimals even for two integers.
SELECT DISTINCT Species FROM PET; +---------+ | Species | +---------+ | Dog | | Cat | | Rabbit | +---------+
DISTINCT works on the whole row you select. With two columns, it removes repeated pairs.
SELECT PName, AgeM FROM PET WHERE AgeM BETWEEN 8 AND 14; +---------+------+ | PName | AgeM | +---------+------+ | Biscuit | 14 | | Mishti | 8 | | Bhalu | 9 | | Momo | 11 | +---------+------+
Mishti at 8 and Biscuit at 14 are both in: BETWEEN includes its ends.
SELECT PName, Species FROM PET
WHERE Species IN ('Cat', 'Rabbit') AND AgeM < 10;
+--------+---------+
| PName | Species |
+--------+---------+
| Mishti | Cat |
| Kaju | Rabbit |
| Pihu | Cat |
+--------+---------+SELECT PName FROM PET WHERE PName LIKE '_i%'; +---------+ | PName | +---------+ | Biscuit | | Mishti | | Simba | | Pihu | +---------+ SELECT PName FROM PET WHERE PName LIKE '____'; +-------+ | PName | +-------+ | Kaju | | Pihu | | Momo | +-------+
One underscore is one character. Four underscores and no % means exactly four.
SELECT PName, Weight FROM PET WHERE Weight IS NULL; +-------+--------+ | PName | Weight | +-------+--------+ | Simba | NULL | | Bhalu | NULL | +-------+--------+ SELECT PName, Weight FROM PET WHERE Weight = NULL; Empty set
A comparison with an unknown value is unknown, never true.
SELECT PName, Weight FROM PET WHERE NOT Weight < 5; +---------+--------+ | PName | Weight | +---------+--------+ | Biscuit | 11.5 | | Rocket | 18.4 | +---------+--------+
Simba and Bhalu are missing. NOT unknown is still unknown.
SELECT PName, Species, AgeM FROM PET ORDER BY Species, AgeM DESC; +---------+---------+------+ | PName | Species | AgeM | +---------+---------+------+ | Simba | Cat | 26 | | Mishti | Cat | 8 | | Pihu | Cat | 5 | | Rocket | Dog | 30 | | Biscuit | Dog | 14 | | Bhalu | Dog | 9 | | Momo | Rabbit | 11 | | Kaju | Rabbit | 6 | +---------+---------+------+
DESC belongs only to the column beside it. Species is still ascending.
SELECT PName, Species, AgeM FROM PET WHERE Species = 'Dog' OR Species = 'Cat' AND AgeM > 20; +---------+---------+------+ | PName | Species | AgeM | +---------+---------+------+ | Biscuit | Dog | 14 | | Rocket | Dog | 30 | | Simba | Cat | 26 | | Bhalu | Dog | 9 | +---------+---------+------+ SELECT PName, Species, AgeM FROM PET WHERE (Species = 'Dog' OR Species = 'Cat') AND AgeM > 20; +--------+---------+------+ | PName | Species | AgeM | +--------+---------+------+ | Rocket | Dog | 30 | | Simba | Cat | 26 | +--------+---------+------+
AND is done before OR, so the first query takes every dog. The second is correct; IN would also do.
SELECT PName FROM PET WHERE Weight = 3.2; return nothing, when the same query with 11.5 finds Biscuit?
SELECT PName FROM PET WHERE Weight = 3.2; Empty set SELECT PName FROM PET WHERE Weight = 11.5; +---------+ | PName | +---------+ | Biscuit | +---------+
FLOAT stores an approximation of 3.2. The value 11.5 can be stored exactly. Use a range for FLOAT columns.
Many rows, one answer
GROUP BY makes one row for each group, and HAVING keeps or drops whole groups. WHERE has already done its work on single rows before any group exists.
| Step | Clause | Question it answers |
|---|---|---|
| 1 | FROM | Which table, or which pair of tables? |
| 2 | WHERE | Which rows stay? |
| 3 | GROUP BY | Which rows belong together? |
| 4 | HAVING | Which groups stay? |
| 5 | SELECT | What is shown for each? |
| 6 | ORDER BY | In what order? |
You write SELECT first and MySQL reaches it fifth. That is why WHERE cannot use COUNT(*): at step 2 nothing has been counted.
SELECT COUNT(*), COUNT(Weight), MIN(AgeM), MAX(AgeM), SUM(AgeM), AVG(AgeM) FROM PET;
SELECT COUNT(*), COUNT(Weight), MIN(AgeM), MAX(AgeM), SUM(AgeM), AVG(AgeM) FROM PET; +----------+---------------+-----------+-----------+-----------+-----------+ | COUNT(*) | COUNT(Weight) | MIN(AgeM) | MAX(AgeM) | SUM(AgeM) | AVG(AgeM) | +----------+---------------+-----------+-----------+-----------+-----------+ | 8 | 6 | 5 | 30 | 109 | 13.6250 | +----------+---------------+-----------+-----------+-----------+-----------+
COUNT(Weight) skips the two NULLs. 109 over 8 is 13.6250.
SELECT COUNT(*), COUNT(Fee), SUM(Fee), AVG(Fee) FROM VISIT; +----------+------------+----------+----------+ | COUNT(*) | COUNT(Fee) | SUM(Fee) | AVG(Fee) | +----------+------------+----------+----------+ | 7 | 6 | 3800 | 633.3333 | +----------+------------+----------+----------+
AVG divides by 6, not by 7. A NULL fee is left out; a fee of 0 would have been counted.
SELECT Species, COUNT(*) AS Pets, MAX(AgeM) AS Oldest FROM PET GROUP BY Species; +---------+------+--------+ | Species | Pets | Oldest | +---------+------+--------+ | Dog | 3 | 30 | | Cat | 3 | 26 | | Rabbit | 2 | 11 | +---------+------+--------+
SELECT Vet, COUNT(*), SUM(Fee) FROM VISIT GROUP BY Vet;
SELECT Vet, COUNT(*), SUM(Fee) FROM VISIT GROUP BY Vet; +---------+----------+----------+ | Vet | COUNT(*) | SUM(Fee) | +---------+----------+----------+ | Dr Sen | 3 | 1100 | | Dr Roy | 3 | 2700 | | Dr Iyer | 1 | NULL | +---------+----------+----------+
The only fee in that group is NULL, so the sum is NULL, not 0.
SELECT Reason, COUNT(*) FROM VISIT GROUP BY Reason HAVING COUNT(*) > 2; +---------+----------+ | Reason | COUNT(*) | +---------+----------+ | Vaccine | 3 | +---------+----------+
SELECT Vet, SUM(Fee) AS Total FROM VISIT WHERE Reason <> 'Injury' GROUP BY Vet; +---------+-------+ | Vet | Total | +---------+-------+ | Dr Sen | 1100 | | Dr Roy | 300 | | Dr Iyer | NULL | +---------+-------+ SELECT Vet, SUM(Fee) AS Total FROM VISIT WHERE Reason <> 'Injury' GROUP BY Vet HAVING SUM(Fee) > 500 ORDER BY Total DESC; +--------+-------+ | Vet | Total | +--------+-------+ | Dr Sen | 1100 | +--------+-------+
The first result is what HAVING sees. Dr Roy had 2700 in Question 27, but only 300 once injuries were removed.
SELECT Vet FROM VISIT WHERE COUNT(*) > 1 GROUP BY Vet; (II) SELECT PName, Species, COUNT(*) FROM PET GROUP BY Species;
SELECT Vet FROM VISIT WHERE COUNT(*) > 1 GROUP BY Vet; ERROR 1111 (HY000): Invalid use of group function SELECT PName, Species, COUNT(*) FROM PET GROUP BY Species; ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'shelter.PET.PName' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
(I) has an aggregate in WHERE; move it to HAVING. In (II), three dogs share one row, so which name should it show? A server with a looser setting may print one of them, and that is worse, since it looks like an answer.
Two tables
A cartesian product pairs every row of one table with every row of the other. An equi-join keeps the pairs whose common column is equal. A natural join does that by itself, on every column name the tables share.
| Cartesian product | Equi-join | Natural join | |
|---|---|---|---|
| Condition | none | you write it: PET.PID = VISIT.PID | automatic, on all shared names |
| Rows for our tables | 8 x 7 = 56 | 7 | 7 |
| Columns with SELECT * | 6 + 6 = 12 | 12, PID twice | 11, PID once |
| Pets with no visit | appear, wrongly paired | do not appear | do not appear |
SELECT COUNT(*) FROM PET, VISIT; +----------+ | COUNT(*) | +----------+ | 56 | +----------+
SELECT PName, Vet, Reason, Fee FROM PET, VISIT WHERE PET.PID = VISIT.PID; +---------+---------+---------+------+ | PName | Vet | Reason | Fee | +---------+---------+---------+------+ | Biscuit | Dr Sen | Vaccine | 400 | | Rocket | Dr Roy | Injury | 1500 | | Mishti | Dr Sen | Vaccine | 400 | | Simba | Dr Roy | Checkup | 300 | | Biscuit | Dr Sen | Checkup | 300 | | Rocket | Dr Roy | Injury | 900 | | Pihu | Dr Iyer | Vaccine | NULL | +---------+---------+---------+------+
Kaju, Bhalu and Momo are absent: no visit matches them.
SELECT P.PName, V.VDate FROM PET P JOIN VISIT V ON P.PID = V.PID WHERE P.Species = 'Cat'; +--------+------------+ | PName | VDate | +--------+------------+ | Mishti | 2026-09-12 | | Simba | 2026-10-12 | | Pihu | 2026-11-09 | +--------+------------+
P and V are table aliases. Once given, use them everywhere in the query.
SELECT Species, SUM(Fee) FROM PET NATURAL JOIN VISIT GROUP BY Species; +---------+----------+ | Species | SUM(Fee) | +---------+----------+ | Dog | 3100 | | Cat | 700 | +---------+----------+
Rabbits have no visits, so they have no group at all.
SELECT PName, COUNT(*) AS Visits, SUM(Fee) AS Spent FROM PET P, VISIT V WHERE P.PID = V.PID GROUP BY PName HAVING COUNT(*) > 1; +---------+--------+-------+ | PName | Visits | Spent | +---------+--------+-------+ | Biscuit | 2 | 700 | | Rocket | 2 | 2400 | +---------+--------+-------+
SELECT PID, PName, Vet FROM PET, VISIT WHERE PET.PID = VISIT.PID;
SELECT PID, PName, Vet FROM PET, VISIT WHERE PET.PID = VISIT.PID; ERROR 1052 (23000): Column 'PID' in field list is ambiguous
Both tables have a PID, and MySQL will not choose. Write PET.PID. A natural join would not need it.
SELECT PName, Vet FROM PET, VISIT WHERE PName = 'Kaju';
SELECT PName, Vet FROM PET, VISIT WHERE PName = 'Kaju'; +-------+---------+ | PName | Vet | +-------+---------+ | Kaju | Dr Sen | | Kaju | Dr Roy | | Kaju | Dr Sen | | Kaju | Dr Roy | | Kaju | Dr Sen | | Kaju | Dr Roy | | Kaju | Dr Iyer | +-------+---------+
The join condition was forgotten, so Kaju is paired with all seven visits. A condition on one table is not a join.
SELECT * FROM PET NATURAL JOIN VISIT; give now, and why?
ALTER TABLE VISIT ADD Weight FLOAT; Query OK, 0 rows affected Records: 0 Duplicates: 0 Warnings: 0 SELECT * FROM PET NATURAL JOIN VISIT; Empty set
Two names are shared now, PID and Weight, and both must match. NULL matches nothing. An equi-join on PID would be unharmed.
The same two visits, joined both ways. Count the PID headings.
SELECT * FROM PET NATURAL JOIN VISIT WHERE Reason = 'Injury'; +-----+--------+---------+------+--------+------------+-----+--------+--------+------+------------+ | PID | PName | Species | AgeM | Weight | Arrived | VNo | Vet | Reason | Fee | VDate | +-----+--------+---------+------+--------+------------+-----+--------+--------+------+------------+ | P03 | Rocket | Dog | 30 | 18.4 | 2026-09-02 | 102 | Dr Roy | Injury | 1500 | 2026-09-03 | | P03 | Rocket | Dog | 30 | 18.4 | 2026-09-02 | 106 | Dr Roy | Injury | 900 | 2026-11-06 | +-----+--------+---------+------+--------+------------+-----+--------+--------+------+------------+
SELECT * FROM PET P, VISIT V WHERE P.PID = V.PID AND Reason = 'Injury'; +-----+--------+---------+------+--------+------------+-----+-----+--------+--------+------+------------+ | PID | PName | Species | AgeM | Weight | Arrived | VNo | PID | Vet | Reason | Fee | VDate | +-----+--------+---------+------+--------+------------+-----+-----+--------+--------+------+------------+ | P03 | Rocket | Dog | 30 | 18.4 | 2026-09-02 | 102 | P03 | Dr Roy | Injury | 1500 | 2026-09-03 | | P03 | Rocket | Dog | 30 | 18.4 | 2026-09-02 | 106 | P03 | Dr Roy | Injury | 900 | 2026-11-06 | +-----+--------+---------+------+--------+------------+-----+-----+--------+--------+------+------------+
To send these queries from a program, continue with Python MySQL connectivity for Class 12. To see them inside a finished application, read the Python and MySQL project.
Now under exam conditions
Thirty minutes, no computer. The marks beside each question follow the sample paper's sizes; the questions are ours, on the same two tables.
SELECT PName FROM PET WHERE PName LIKE '%o'; returns: DELETE FROM PET; removes the table PET from the database. Reason: DROP TABLE removes both the rows and the structure.
SHOW DATABASES; (II) DESCRIBE VISIT; or DESC VISIT;WHERE Fee > 300. HAVING tests groups after GROUP BY: HAVING SUM(Fee) > 300.SELECT Vet, MAX(Fee) FROM VISIT GROUP BY Vet; (II) SELECT PID, Reason FROM VISIT WHERE Vet LIKE '%y%'; (III) SELECT COUNT(PID), COUNT(DISTINCT PID) FROM VISIT; (IV) SELECT SUM(Fee) FROM VISIT WHERE Reason IN ('Vaccine', 'Checkup');
(I) +---------+----------+ | Vet | MAX(Fee) | +---------+----------+ | Dr Sen | 400 | | Dr Roy | 1500 | | Dr Iyer | NULL | +---------+----------+ (II) +-----+---------+ | PID | Reason | +-----+---------+ | P03 | Injury | | P05 | Checkup | | P03 | Injury | | P07 | Vaccine | +-----+---------+ (III) +------------+---------------------+ | COUNT(PID) | COUNT(DISTINCT PID) | +------------+---------------------+ | 7 | 5 | +------------+---------------------+ (IV) +----------+ | SUM(Fee) | +----------+ | 1400 | +----------+
In (II) both Roy and Iyer contain y. Copy the headings too: they are part of the output.
SELECT Reason, COUNT(*) AS Visits FROM VISIT GROUP BY Reason HAVING COUNT(*) > 1; +---------+--------+ | Reason | Visits | +---------+--------+ | Vaccine | 3 | | Injury | 2 | | Checkup | 2 | +---------+--------+ SELECT DISTINCT Vet FROM VISIT; +---------+ | Vet | +---------+ | Dr Sen | | Dr Roy | | Dr Iyer | +---------+ SELECT * FROM VISIT WHERE VDate >= '2026-11-01'; +-----+-----+---------+---------+------+------------+ | VNo | PID | Vet | Reason | Fee | VDate | +-----+-----+---------+---------+------+------------+ | 106 | P03 | Dr Roy | Injury | 900 | 2026-11-06 | | 107 | P07 | Dr Iyer | Vaccine | NULL | 2026-11-09 | +-----+-----+---------+---------+------+------------+ SELECT VNo, Fee FROM VISIT ORDER BY Fee DESC; +-----+------+ | VNo | Fee | +-----+------+ | 102 | 1500 | | 106 | 900 | | 101 | 400 | | 103 | 400 | | 104 | 300 | | 105 | 300 | | 107 | NULL | +-----+------+
NULL comes last in descending order and first in ascending order.
UPDATE VISIT SET Fee = Fee + 50 WHERE Reason = 'Vaccine';
Query OK, 2 rows affected
Rows matched: 3 Changed: 2 Warnings: 0
SELECT VNo, Fee FROM VISIT WHERE Reason = 'Vaccine';
+-----+------+
| VNo | Fee |
+-----+------+
| 101 | 450 |
| 103 | 450 |
| 107 | NULL |
+-----+------+
SELECT PName, Species FROM PET
WHERE Arrived BETWEEN '2026-10-01' AND '2026-10-31';
+-------+---------+
| PName | Species |
+-------+---------+
| Simba | Cat |
| Bhalu | Dog |
+-------+---------+
SELECT V.VNo, V.Reason, V.VDate FROM PET P, VISIT V
WHERE P.PID = V.PID AND P.PName IN ('Biscuit', 'Simba');
+-----+---------+------------+
| VNo | Reason | VDate |
+-----+---------+------------+
| 101 | Vaccine | 2026-08-10 |
| 104 | Checkup | 2026-10-12 |
| 105 | Checkup | 2026-10-30 |
+-----+---------+------------+
SELECT PName, Vet FROM PET NATURAL JOIN VISIT
ORDER BY PName;
+---------+---------+
| PName | Vet |
+---------+---------+
| Biscuit | Dr Sen |
| Biscuit | Dr Sen |
| Mishti | Dr Sen |
| Pihu | Dr Iyer |
| Rocket | Dr Roy |
| Rocket | Dr Roy |
| Simba | Dr Roy |
+---------+---------+Three rows matched in (I) and two changed: NULL + 50 is NULL. The second query only shows that.
| Trap | Seen in | Habit |
|---|---|---|
= NULL | Q19 | Say "is", write IS NULL |
| AVG over a column with NULL | Q25 | Count the values, not the rows, before dividing |
| Aggregate in WHERE | Q30 | If it counts or adds, it goes in HAVING |
| A column that is neither grouped nor aggregated | Q30 | Every plain column after SELECT must be in GROUP BY |
| AND mixed with OR | Q22 | Put brackets round the OR part |
| Join condition missing | Q37 | Two tables in FROM: write the link before anything else |
| Shared column without a table name | Q36 | Prefix every column that both tables have |
| Natural join on an extra shared column | Q38 | List the common names before you trust it |
In a one to one class you write the result grid by hand, NULLs included, before the teacher presses Enter. The gap between the two is the lesson.
The practical asks for four queries on one or two tables. We set a fresh pair of tables and you type, test and correct against the clock.
Each query is right or it is not. The teacher shows which row your version let in or lost, so the same slip is not repeated.
Go further with the Class 12 CS MCQ test, important questions by unit, and a whole paper under time on the 2026-27 sample paper. Spoken SQL answers are in the viva bank.
One to one, at your own timing
A wrong query often runs without complaint and returns a believable table, so practice alone can fix a mistake in place. Our SQL classes are personalised one to one only, at a time you set. The priority demo is a complete class you can take before enrolling, and its fee is adjusted against the first month; a free demo class is the shorter look. Fees are monthly, nothing is charged for admission, and you may leave at any month end.
Before you enrol · Try a class
a full live class of about 45 to 60 minutes
The classes · Choose your own timing
₹4,999
per month, 4 private classes, fully flexible timingtwo private classes a week, at a time set with you
MySQL need not be installed for the first class. If it is missing or refuses to start, the teacher helps you set it up, and the practice then happens on your own machine, where the lab test habits are made.
Studying outside India?
Whether your CBSE school is in Abu Dhabi, Jeddah or Bangkok, the database unit is the same 20 marks. Pick a morning, an evening or a weekend hour by your own clock.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India every Indian city | Indian time | Any time you choose | Personalised 1-on-1 |
| UAE and Oman Dubai, Abu Dhabi, Sharjah, Muscat | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Saudi Arabia, Qatar, Kuwait, Bahrain Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama | 2 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Nepal Kathmandu | 15 min ahead of India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Ethiopia and East Africa Addis Ababa and East Africa Time | 2 h 30 min behind India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore and Malaysia Singapore, Kuala Lumpur | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
Typing matters in SQL, so you share your screen and we read the query as you write it. A missed semicolon is noticed on the spot, not a week later.
What families say
Real reviews from real families. We neither write nor commission them.
★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
★★★★★
"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."
Samriddha Mondal
Student
★★★★★
"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."
Vansh Agarwal
Student
★★★★★
"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."
Sonam Oswal
Parent of Dhairya
★★★★★
"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."
Sonu Goyal
Parent
★★★★★
"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."
Ritu Kedia
Parent
The rest of the Class 12 series
Every page in the CBSE Class 12 Computer Science series, grouped by what you need.
CBSE Class 12 Informatics Practices (065): Class 12 IP practical file Class 12 IP project with source code Class 12 IP sample paper practice Class 12 IP important questions
CBSE Class 12 Information Technology (802): IT 802 practical and project file IT 802 Java notes and programs IT 802 notes
CBSE Class 11 CS, IP and AI: Class 11 CS practical file Class 11 IP practical file CS or IP in Class 11
ISC Computer Science (868): ISC Class 12 CS syllabus 2027 ISC Class 12 CS practice paper ISC Class 12 practical questions solved ISC Boolean algebra and K-maps
Program lists with output: Class 12 CS practical file 20 Python programs for Class 12 Menu-driven programs in Python
SQL questions, answered
Database Management is 20 of the 70 theory marks in CBSE 083 for 2026-27. In the sample paper, 4 of those 20 are for a Python-MySQL program and 16 for SQL and relational theory. The practical adds 4 marks for SQL queries in the lab test.
GROUP BY with HAVING, aggregates on a column that has NULL, LIKE patterns, BETWEEN and IN, ORDER BY on two columns, UPDATE, ALTER TABLE for a column or primary key, and an equi-join of two tables with a condition. The sample paper uses most of these in Questions 27, 32 and 34.
An equi-join needs the condition written out and, with SELECT *, shows the common column twice. A natural join matches every column name the two tables share and shows each once. On our tables the first gives 12 columns, the second 11.
WHERE filters single rows before they are grouped, so it cannot contain COUNT, SUM, AVG, MAX or MIN. HAVING filters groups after GROUP BY and usually does contain one. A query may use both, with WHERE written first.
They are not listed in the 083 syllabus for 2026-27. The joins named are cartesian product, equi-join and natural join. Questions such as "pets that never visited" need an outer join or a subquery, so they are outside what is named.
Keywords such as SELECT may be typed in any case in MySQL. Write keywords in capitals for clarity and copy table and column names as the question spells them. Keep text values exactly as given, since you cannot be sure how a comparison treats case.
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. Any of the last four may be absent, but they may not change places. MySQL works them out in a different order: FROM and WHERE first, then groups, then SELECT, then sorting.
Yes, write the column headings exactly as the query would show them, including an alias or a heading such as MAX(Fee). Write NULL where the value is missing, not a blank or a zero.
No. IP (065) adds math, text and date functions and gives SQL 25 theory marks. CS (083) has no such functions but adds natural join and the Python interface. SELECT, GROUP BY, HAVING and equi-join are common to both.
Modern Age Coders teaches 083 SQL live and personalised one to one at your own timing. Book a priority demo for a full class of about 45 to 60 minutes with a written skill report; its fee is adjusted against the first month if you enrol. A free demo class is available as well.
Start
The free demo class is enough to try a few queries on a table you have not seen and find out whether SELECT, grouping or joins is the weak step.
The priority demo goes the full distance: ten queries, the failed ones rebuilt with a teacher, and a written skill report. You choose the slot, and the fee is adjusted against the first month if you enrol.
New to both SQL and Python? The practical file guide shows what your school will want to see from each.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Every class is live video. The form requests a callback and reserves nothing.
A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.
Book a priority demo