★★★★★
"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 · Informatics Practices, code 065 · Unit 2, 25 marks
A sky-watching club keeps two tables: what can be seen, and who saw it. These class 12 IP SQL questions with answers ask them everything Unit 2 of CBSE 065 allows, from a one-mark LENGTH() to a four-mark join with HAVING. Cover the answer, write yours on paper, then open the MySQL grid and compare column headings as well as values.
Live one to one · 40 original questions · real MySQL grids · your own days and hours
Start here
The first teaches Unit 2 inside the whole IP syllabus. The second takes the same grouping idea into pandas. The third is for a student who wants months of SQL and nothing else.

Unit 2 and the rest / 065
SQL functions, GROUP BY and joins come in the second half of Class 12, with bridge revision of Class 11 SQL for those who join late.
Open the course →
GROUP BY in pandas
Filtering, grouping and joining real datasets with pandas, then honest charts. The questions feel familiar after this unit.
Open the course →
Only SQL, slowly
CREATE to SELECT in the first month, string, number and date functions with grouping in the second, joins and design in the third.
Open the course →Ans. The short version
Class 12 IP SQL questions with answers should cover Unit 2 of CBSE Informatics Practices (065), which carries 25 of the 70 theory marks in 2026-27: math functions (POWER, ROUND, MOD), text functions such as MID, INSTR and TRIM, date functions such as MONTHNAME and DAYNAME, aggregate functions, GROUP BY, HAVING, ORDER BY, equi-join of two tables, and the Class 11 commands. This page has 40 original questions with MySQL output. Modern Age Coders teaches the unit live, personalised one to one at your own timing; a priority demo lets you try one class first.
Q. Which functions can be asked?
The 065 syllabus names 3 math, 10 text, 7 date and 5 aggregate functions. The first three kinds work on one row and give one value per row; an aggregate function takes many rows and gives one value.
| Call | MySQL returns | Remember |
|---|---|---|
POWER(2, 5) | 32 | Base first, then the power |
ROUND(2745.638, 2) | 2745.64 | Two places after the point |
ROUND(2745.638) | 2746 | No second argument means whole number |
ROUND(2745.638, -2) | 2700 | Negative means hundreds |
MOD(4, 29) | 4 | Smaller divided by larger: itself |
DATE('2026-11-14 21:40:00') | 2026-11-14 | Drops the time |
DAY('2027-03-31') | 31 | A number |
MONTH('2027-03-31') | 3 | A number |
MONTHNAME('2026-11-14') | November | A word |
YEAR('2027-03-31') | 2027 | Four digits |
DAYNAME('2026-11-14') | Saturday | A word |
NOW() | the present date and time | No argument, but the brackets stay |
| Call | MySQL returns | Remember |
|---|---|---|
UPPER('Saturn') | SATURN | Same as UCASE() |
LOWER('Saturn') | saturn | Same as LCASE() |
MID('Saturn', 3, 2) | tu | Start, then how many; counting begins at 1 |
SUBSTR('Saturn', -3) | urn | Negative start counts from the end |
LENGTH('Orion Nebula') | 12 | Spaces count |
LEFT('Saturn', 3) | Sat | From the left end |
RIGHT('Saturn', 3) | urn | From the right end |
INSTR('Andromeda', 'd') | 3 | First match only |
INSTR('Saturn', 'x') | 0 | Not found is 0, not an error |
TRIM(' Saturn ') | Saturn | Both ends; LTRIM and RTRIM do one each |
MID, SUBSTR and SUBSTRING are three names for one function. Python counts from 0 and SQL from 1, which is why a student strong in pandas is often one letter out here.
Aggregate functions: MAX(), MIN(), AVG(), SUM() and COUNT(), plus COUNT(*). All except COUNT(*) skip NULL.
Q. Can you get the column heading right too?
Sixteen questions, all on the two tables below. Write the command for a task, and the heading with the value for an output question.
SELECT * FROM SKYOBJ; +------+--------------+---------+--------+ | Code | OName | Kind | Points | +------+--------------+---------+--------+ | JUP | Jupiter | Planet | 3 | | M13 | Hercules | Cluster | 8 | | M31 | Andromeda | Galaxy | 10 | | M42 | Orion Nebula | Nebula | 6 | | M45 | Pleiades | Cluster | 4 | | SAT | Saturn | Planet | 5 | +------+--------------+---------+--------+
SELECT * FROM SKYLOG; +-------+---------------+------+------------+-------+--------+ | LogNo | Watcher | Code | LDate | Hours | Photos | +-------+---------------+------+------------+-------+--------+ | 1 | Zoya Khan | M45 | 2026-01-16 | 1.75 | 12 | | 2 | Tenzin Bhutia | M42 | 2026-01-23 | 2.40 | 30 | | 3 | Meera Das | JUP | 2026-02-06 | 0.85 | NULL | | 4 | Zoya Khan | M42 | 2026-02-13 | 3.15 | 26 | | 5 | Aarush Nair | JUP | 2026-03-07 | 1.25 | 9 | | 6 | Tenzin Bhutia | M31 | 2026-10-10 | 2.65 | NULL | | 7 | Meera Das | M45 | 2026-10-17 | 1.50 | 14 | | 8 | Aarush Nair | M31 | 2026-11-07 | 2.05 | 18 | | 9 | Zoya Khan | SAT | 2026-11-14 | 0.95 | 7 | +-------+---------------+------+------------+-------+--------+
CREATE TABLE SKYOBJ (
Code CHAR(3) PRIMARY KEY,
OName VARCHAR(20),
Kind VARCHAR(10),
Points INT);
INSERT INTO SKYOBJ VALUES
('M31','Andromeda','Galaxy',10),
('M42','Orion Nebula','Nebula',6),
('M45','Pleiades','Cluster',4),
('JUP','Jupiter','Planet',3),
('SAT','Saturn','Planet',5),
('M13','Hercules','Cluster',8);
CREATE TABLE SKYLOG (
LogNo INT PRIMARY KEY,
Watcher VARCHAR(15),
Code CHAR(3),
LDate DATE,
Hours DECIMAL(4,2),
Photos INT);
INSERT INTO SKYLOG VALUES
(1,'Zoya Khan','M45','2026-01-16',1.75,12),
(2,'Tenzin Bhutia','M42','2026-01-23',2.40,30),
(3,'Meera Das','JUP','2026-02-06',0.85,NULL),
(4,'Zoya Khan','M42','2026-02-13',3.15,26),
(5,'Aarush Nair','JUP','2026-03-07',1.25,9),
(6,'Tenzin Bhutia','M31','2026-10-10',2.65,NULL),
(7,'Meera Das','M45','2026-10-17',1.50,14),
(8,'Aarush Nair','M31','2026-11-07',2.05,18),
(9,'Zoya Khan','SAT','2026-11-14',0.95,7);SELECT UPPER(Watcher), LENGTH(Watcher) FROM SKYLOG WHERE LogNo = 2; +----------------+-----------------+ | UPPER(Watcher) | LENGTH(Watcher) | +----------------+-----------------+ | TENZIN BHUTIA | 13 | +----------------+-----------------+
UCASE() is the same function. LENGTH counted the space, so the answer is 13 and not 12.
SELECT LOWER(LEFT(OName, 3)) FROM SKYOBJ WHERE Kind = 'Planet'; +-----------------------+ | LOWER(LEFT(OName, 3)) | +-----------------------+ | jup | | sat | +-----------------------+
The inner function works first. LEFT(LOWER(OName), 3) would give the same text.
SELECT MID(OName, 3, 4), RIGHT(Kind, 3) FROM SKYOBJ WHERE Code = 'M42';
+------------------+----------------+ | MID(OName, 3, 4) | RIGHT(Kind, 3) | +------------------+----------------+ | ion | ula | +------------------+----------------+
Characters 3 to 6 of Orion Nebula are i, o, n and a space. The grid hides the space; LENGTH() of that value returns 4. In an answer book, write it as "ion " with the gap shown.
SELECT OName, INSTR(OName, 'e') FROM SKYOBJ;
+--------------+-------------------+ | OName | INSTR(OName, 'e') | +--------------+-------------------+ | Jupiter | 6 | | Hercules | 2 | | Andromeda | 7 | | Orion Nebula | 8 | | Pleiades | 3 | | Saturn | 0 | +--------------+-------------------+
One row. Saturn has no letter e, so INSTR gives 0. Elsewhere it gives the position of the first e.
SELECT LEFT(Watcher, INSTR(Watcher, ' ') - 1) FROM SKYLOG WHERE LDate > '2026-10-31'; +----------------------------------------+ | LEFT(Watcher, INSTR(Watcher, ' ') - 1) | +----------------------------------------+ | Aarush | | Zoya | +----------------------------------------+
INSTR finds the space. One less than that is the number of letters to keep. Names without a space would come out blank.
SELECT Code, SUBSTR(Code, 2) FROM SKYOBJ WHERE LEFT(Code, 1) = 'M'; +------+-----------------+ | Code | SUBSTR(Code, 2) | +------+-----------------+ | M13 | 13 | | M31 | 31 | | M42 | 42 | | M45 | 45 | +------+-----------------+
With no third argument, SUBSTR runs to the end. LEFT(Code, 1) = 'M' does the filtering with a listed function.
SELECT LENGTH(' Saturn '), LENGTH(LTRIM(' Saturn ')),
LENGTH(RTRIM(' Saturn ')), LENGTH(TRIM(' Saturn '));+---------------------+----------------------------+----------------------------+---------------------------+
| LENGTH(' Saturn ') | LENGTH(LTRIM(' Saturn ')) | LENGTH(RTRIM(' Saturn ')) | LENGTH(TRIM(' Saturn ')) |
+---------------------+----------------------------+----------------------------+---------------------------+
| 9 | 7 | 8 | 6 |
+---------------------+----------------------------+----------------------------+---------------------------+Six letters and three spaces make 9. LTRIM removes two, RTRIM one, TRIM all three. None of them touches a space between words.
SELECT OName FROM SKYOBJ WHERE RIGHT(OName, 1) = 's'; +----------+ | OName | +----------+ | Hercules | | Pleiades | +----------+
RIGHT(OName, 1) is the last letter. The official scheme uses this same idea for such a question.
SELECT POWER(2, 5), MOD(29, 4),
ROUND(746.28, 1), ROUND(746.28, -1);+-------------+------------+------------------+-------------------+ | POWER(2, 5) | MOD(29, 4) | ROUND(746.28, 1) | ROUND(746.28, -1) | +-------------+------------+------------------+-------------------+ | 32 | 1 | 746.3 | 750 | +-------------+------------+------------------+-------------------+
A negative second argument rounds to the left of the point: -1 means tens. 29 = 4 x 7 + 1, so MOD is 1.
SELECT LogNo, Hours, ROUND(Hours, 1), ROUND(Hours) FROM SKYLOG WHERE Code = 'M42'; +-------+-------+-----------------+--------------+ | LogNo | Hours | ROUND(Hours, 1) | ROUND(Hours) | +-------+-------+-----------------+--------------+ | 2 | 2.40 | 2.4 | 2 | | 4 | 3.15 | 3.2 | 3 | +-------+-------+-----------------+--------------+
ROUND with one argument rounds to a whole number. 3.15 becomes 3.2 because the digit after the kept place is 5.
SELECT LogNo, Watcher FROM SKYLOG WHERE MOD(LogNo, 4) = 0; +-------+-------------+ | LogNo | Watcher | +-------+-------------+ | 4 | Zoya Khan | | 8 | Aarush Nair | +-------+-------------+
MOD(LogNo, 4) = 0 tests divisibility. For odd numbers use MOD(LogNo, 2) = 1.
SELECT OName, POWER(Points, 2) FROM SKYOBJ WHERE Kind = 'Planet'; +---------+------------------+ | OName | POWER(Points, 2) | +---------+------------------+ | Jupiter | 9 | | Saturn | 25 | +---------+------------------+
POWER(Points, 2) is Points multiplied by itself. MySQL accepts POW too, but write the name in the syllabus.
SELECT LogNo, DAY(LDate), MONTHNAME(LDate), DAYNAME(LDate) FROM SKYLOG WHERE MONTH(LDate) = 11; +-------+------------+------------------+----------------+ | LogNo | DAY(LDate) | MONTHNAME(LDate) | DAYNAME(LDate) | +-------+------------+------------------+----------------+ | 8 | 7 | November | Saturday | | 9 | 14 | November | Saturday | +-------+------------+------------------+----------------+
MONTH() returns a number, so it is compared with 11 and not with a word. MONTHNAME() would be compared with 'November'.
SELECT Watcher, LDate FROM SKYLOG WHERE DAYNAME(LDate) = 'Friday' AND Hours > 2; +---------------+------------+ | Watcher | LDate | +---------------+------------+ | Tenzin Bhutia | 2026-01-23 | | Zoya Khan | 2026-02-13 | +---------------+------------+
The weekday is worked out from the date, so it needs no column of its own.
SELECT DATE('2026-11-14 21:40:00'),
DAYNAME('2027-03-31'), YEAR('2027-03-31');+-----------------------------+-----------------------+--------------------+
| DATE('2026-11-14 21:40:00') | DAYNAME('2027-03-31') | YEAR('2027-03-31') |
+-----------------------------+-----------------------+--------------------+
| 2026-11-14 | Wednesday | 2027 |
+-----------------------------+-----------------------+--------------------+DATE() cuts the time away. The second and third columns describe the day of your theory paper.
NOW() different from the other date functions here? [1] Q. What does MySQL do first?
GROUP BY collects rows that share a value and gives one result row for each collection. HAVING then keeps or drops whole groups, as WHERE does for single rows.
Read this requirement: for sessions of at least one hour, show each watcher's number of sessions and total hours, only if the total is above 3 hours, highest first. Here is the query growing, with the rows left after each stage.
SELECT Watcher, Hours FROM SKYLOG WHERE Hours >= 1 ORDER BY Watcher; +---------------+-------+ | Watcher | Hours | +---------------+-------+ | Aarush Nair | 1.25 | | Aarush Nair | 2.05 | | Meera Das | 1.50 | | Tenzin Bhutia | 2.40 | | Tenzin Bhutia | 2.65 | | Zoya Khan | 1.75 | | Zoya Khan | 3.15 | +---------------+-------+
Logs 3 and 9 are under an hour, so seven rows remain. Sorted here only so that you can see the future groups.
SELECT Watcher, COUNT(*), SUM(Hours) FROM SKYLOG WHERE Hours >= 1 GROUP BY Watcher; +---------------+----------+------------+ | Watcher | COUNT(*) | SUM(Hours) | +---------------+----------+------------+ | Zoya Khan | 2 | 4.90 | | Tenzin Bhutia | 2 | 5.05 | | Aarush Nair | 2 | 3.30 | | Meera Das | 1 | 1.50 | +---------------+----------+------------+
Four watchers, four rows. Zoya has two sessions here, not three.
SELECT Watcher, COUNT(*), SUM(Hours) FROM SKYLOG WHERE Hours >= 1 GROUP BY Watcher HAVING SUM(Hours) > 3; +---------------+----------+------------+ | Watcher | COUNT(*) | SUM(Hours) | +---------------+----------+------------+ | Zoya Khan | 2 | 4.90 | | Tenzin Bhutia | 2 | 5.05 | | Aarush Nair | 2 | 3.30 | +---------------+----------+------------+
Meera, with 1.50 hours, is gone.
SELECT Watcher, COUNT(*), SUM(Hours) FROM SKYLOG WHERE Hours >= 1 GROUP BY Watcher HAVING SUM(Hours) > 3 ORDER BY SUM(Hours) DESC; +---------------+----------+------------+ | Watcher | COUNT(*) | SUM(Hours) | +---------------+----------+------------+ | Tenzin Bhutia | 2 | 5.05 | | Zoya Khan | 2 | 4.90 | | Aarush Nair | 2 | 3.30 | +---------------+----------+------------+
Sorting is always last, on rows that have survived everything else.
| Point of difference | WHERE | HAVING |
|---|---|---|
| Works on | single rows | groups |
| Happens | before grouping | after grouping |
| Aggregate function inside? | not allowed | allowed, and usual |
| Needs GROUP BY? | no | used with it |
| In the query above | WHERE Hours >= 1 | HAVING SUM(Hours) > 3 |
SELECT COUNT(*), COUNT(Photos), SUM(Photos), AVG(Photos) FROM SKYLOG;
+----------+---------------+-------------+-------------+ | COUNT(*) | COUNT(Photos) | SUM(Photos) | AVG(Photos) | +----------+---------------+-------------+-------------+ | 9 | 7 | 116 | 16.5714 | +----------+---------------+-------------+-------------+
Nine rows, but two have no photo count. COUNT(Photos), SUM and AVG ignore NULL, so the average is 116 divided by 7, not by 9.
SELECT MIN(LDate), MAX(LDate), MAX(Hours) FROM SKYLOG; +------------+------------+------------+ | MIN(LDate) | MAX(LDate) | MAX(Hours) | +------------+------------+------------+ | 2026-01-16 | 2026-11-14 | 3.15 | +------------+------------+------------+
MIN of a date column is the earliest date.
SELECT Kind, COUNT(*), MAX(Points) FROM SKYOBJ GROUP BY Kind ORDER BY Kind; +---------+----------+-------------+ | Kind | COUNT(*) | MAX(Points) | +---------+----------+-------------+ | Cluster | 2 | 8 | | Galaxy | 1 | 10 | | Nebula | 1 | 6 | | Planet | 2 | 5 | +---------+----------+-------------+
The column after GROUP BY is the one you show beside the aggregate functions.
SELECT MONTHNAME(LDate), COUNT(*), SUM(Hours) FROM SKYLOG GROUP BY MONTHNAME(LDate) HAVING COUNT(*) > 1; +------------------+----------+------------+ | MONTHNAME(LDate) | COUNT(*) | SUM(Hours) | +------------------+----------+------------+ | January | 2 | 4.15 | | February | 2 | 4.00 | | October | 2 | 4.15 | | November | 2 | 3.00 | +------------------+----------+------------+
GROUP BY can use a function of a column. March has a single log, so HAVING drops it.
SELECT Code, MIN(Hours), MAX(Hours) FROM SKYLOG GROUP BY Code HAVING COUNT(*) = 2 ORDER BY Code;
+------+------------+------------+ | Code | MIN(Hours) | MAX(Hours) | +------+------------+------------+ | JUP | 0.85 | 1.25 | | M31 | 2.05 | 2.65 | | M42 | 2.40 | 3.15 | | M45 | 1.50 | 1.75 | +------+------------+------------+
SAT has one log and is dropped. The condition is on COUNT(*) although COUNT(*) is not displayed, and that is allowed.
SELECT Code, COUNT(*), COUNT(Photos), AVG(Photos) FROM SKYLOG GROUP BY Code ORDER BY Code;
+------+----------+---------------+-------------+ | Code | COUNT(*) | COUNT(Photos) | AVG(Photos) | +------+----------+---------------+-------------+ | JUP | 2 | 1 | 9.0000 | | M31 | 2 | 1 | 18.0000 | | M42 | 2 | 2 | 28.0000 | | M45 | 2 | 2 | 13.0000 | | SAT | 1 | 1 | 7.0000 | +------+----------+---------------+-------------+
JUP and M31 have two logs but one photo count each. Their average is that single number divided by 1.
SELECT Kind, OName, Points FROM SKYOBJ ORDER BY Kind, Points DESC; +---------+--------------+--------+ | Kind | OName | Points | +---------+--------------+--------+ | Cluster | Hercules | 8 | | Cluster | Pleiades | 4 | | Galaxy | Andromeda | 10 | | Nebula | Orion Nebula | 6 | | Planet | Saturn | 5 | | Planet | Jupiter | 3 | +---------+--------------+--------+
DESC belongs only to Points. Kind stays ascending, which is the default.
SELECT Watcher, COUNT(*) FROM SKYLOG WHERE COUNT(*) > 2 GROUP BY Watcher;
ERROR 1111 (HY000): Invalid use of group function
SELECT Watcher, COUNT(*) FROM SKYLOG GROUP BY Watcher HAVING COUNT(*) > 2; +-----------+----------+ | Watcher | COUNT(*) | +-----------+----------+ | Zoya Khan | 3 | +-----------+----------+
WHERE looks at one row at a time, before any group exists, so it cannot use COUNT(*). Conditions on a group go in HAVING, after GROUP BY.
One more query worth testing on your own machine is SELECT Watcher, LDate, COUNT(*) FROM SKYLOG GROUP BY Watcher;. MySQL 26 refuses it, because a watcher has many dates and only one can fill the cell. Show the grouped column and aggregate functions, nothing else. The same thinking in Python is on DataFrame for Class 12 IP.
Q. How do two tables become one answer?
An equi-join pairs the rows of two tables where a column in one equals a column in the other. In 065 it is written with both table names after FROM and the equality in WHERE.
Here it is Code. It is the primary key of SKYOBJ, so it is unique there. In SKYLOG the same code appears once for every log.
SKYLOG.Code = SKYOBJ.Code. With two tables you need one such condition. Other conditions follow with AND.
A name found in both tables must carry its table name, wherever it appears in the query.
SELECT COUNT(*) FROM SKYLOG, SKYOBJ;
+----------+ | COUNT(*) | +----------+ | 54 | +----------+
9 logs x 6 objects = 54. Every log is paired with every object, so 45 of the pairs are meaningless.
SELECT Watcher, OName, Hours FROM SKYLOG, SKYOBJ WHERE SKYLOG.Code = SKYOBJ.Code AND Hours > 2; +---------------+--------------+-------+ | Watcher | OName | Hours | +---------------+--------------+-------+ | Tenzin Bhutia | Orion Nebula | 2.40 | | Zoya Khan | Orion Nebula | 3.15 | | Tenzin Bhutia | Andromeda | 2.65 | | Aarush Nair | Andromeda | 2.05 | +---------------+--------------+-------+
One mark for both tables in FROM with the columns, one for the join condition together with the filter.
SELECT LogNo, OName, DAYNAME(LDate) FROM SKYLOG, SKYOBJ WHERE SKYLOG.Code = SKYOBJ.Code AND Kind = 'Planet' ORDER BY LogNo; +-------+---------+----------------+ | LogNo | OName | DAYNAME(LDate) | +-------+---------+----------------+ | 3 | Jupiter | Friday | | 5 | Jupiter | Saturday | | 9 | Saturn | Saturday | +-------+---------+----------------+
Kind is in SKYOBJ and LDate in SKYLOG. After the join they stand in one row.
SELECT Watcher, Code, OName FROM SKYLOG, SKYOBJ WHERE SKYLOG.Code = SKYOBJ.Code;
ERROR 1052 (23000): Column 'Code' in field list is ambiguous
Code is in both tables. Write SKYLOG.Code or SKYOBJ.Code; either is right, since they are equal in every joined row.
SELECT Kind, COUNT(*), SUM(Hours) FROM SKYLOG, SKYOBJ WHERE SKYLOG.Code = SKYOBJ.Code GROUP BY Kind ORDER BY SUM(Hours) DESC; +---------+----------+------------+ | Kind | COUNT(*) | SUM(Hours) | +---------+----------+------------+ | Nebula | 2 | 5.55 | | Galaxy | 2 | 4.70 | | Cluster | 2 | 3.25 | | Planet | 3 | 3.05 | +---------+----------+------------+
The join condition goes in WHERE, before GROUP BY. The two clusters appear as one row, and only Pleiades was ever logged.
SELECT Watcher, SUM(Points) FROM SKYLOG, SKYOBJ WHERE SKYLOG.Code = SKYOBJ.Code GROUP BY Watcher HAVING SUM(Points) >= 13 ORDER BY SUM(Points) DESC; +---------------+-------------+ | Watcher | SUM(Points) | +---------------+-------------+ | Tenzin Bhutia | 16 | | Zoya Khan | 15 | | Aarush Nair | 13 | +---------------+-------------+
One mark each for the join, the grouping with SUM, HAVING, and the order. Check one by hand: Zoya logged M45, M42 and SAT, 4 + 6 + 5 = 15.
SELECT UPPER(LEFT(OName, 4)), ROUND(Hours) FROM SKYLOG L, SKYOBJ O WHERE L.Code = O.Code AND Photos IS NULL;
+-----------------------+--------------+ | UPPER(LEFT(OName, 4)) | ROUND(Hours) | +-----------------------+--------------+ | JUPI | 1 | | ANDR | 3 | +-----------------------+--------------+
L and O are names given to the tables for this query. Two logs have NULL photos: log 3 on Jupiter, 0.85 rounded to 1, and log 6 on Andromeda, 2.65 rounded to 3.
Q. Does Class 11 SQL come back?
Yes. Unit 2 begins with revision of Class 11 SQL, and Question 37 of the 2026-27 sample paper gives five marks to INSERT, UPDATE, DELETE, ALTER and DROP as one of its two options.
SELECT LogNo, Watcher FROM SKYLOG WHERE Photos IS NULL; +-------+---------------+ | LogNo | Watcher | +-------+---------------+ | 3 | Meera Das | | 6 | Tenzin Bhutia | +-------+---------------+
WHERE Photos = NULL? SELECT Watcher, Hours FROM SKYLOG WHERE Hours BETWEEN 1.25 AND 1.75; +-------------+-------+ | Watcher | Hours | +-------------+-------+ | Zoya Khan | 1.75 | | Aarush Nair | 1.25 | | Meera Das | 1.50 | +-------------+-------+
BETWEEN includes both limits, so 1.25 and 1.75 are in the answer.
DELETE FROM SKYOBJ WHERE Code = 'M13'; DROP removes the table itself, rows and structure: DROP TABLE SKYOBJ;ALTER TABLE SKYOBJ ADD Season VARCHAR(10); UPDATE changes the values in rows: UPDATE SKYOBJ SET Points = 7 WHERE Code = 'SAT';ALTER TABLE SKYOBJ ADD Season VARCHAR(10);
INSERT INTO SKYOBJ
VALUES ('MAR', 'Mars', 'Planet', 4, 'Summer');
UPDATE SKYOBJ SET Points = Points + 2
WHERE Kind = 'Cluster';
DELETE FROM SKYOBJ WHERE Code = 'JUP';
DROP TABLE SKYOBJ;+------+--------------+---------+--------+--------+ | Code | OName | Kind | Points | Season | +------+--------------+---------+--------+--------+ | M13 | Hercules | Cluster | 10 | NULL | | M31 | Andromeda | Galaxy | 10 | NULL | | M42 | Orion Nebula | Nebula | 6 | NULL | | M45 | Pleiades | Cluster | 6 | NULL | | MAR | Mars | Planet | 4 | Summer | | SAT | Saturn | Planet | 5 | NULL | +------+--------------+---------+--------+--------+
The old rows show NULL under Season, because nothing was stored there. Without the WHERE in (iii) every object would have gained 2 points.
| Question in the 2026-27 SQP | Marks | How the scheme splits them |
|---|---|---|
| 26, two short queries | 2 | 1 for each |
| 31, three queries on one table | 3 | 1 for each |
| 32, three outputs, with a choice | 3 | 1 for each |
| 34, two bigger queries or outputs, with a choice | 4 | 2 for each |
| 37, five commands or five queries, with a choice | 5 | 1 for each |
With one mark riding on a whole command, spelling a column the way the question spells it matters more than speed. For output questions the scheme prints column headings above the values, so write them too.
In class a query is written by hand, read back as a sentence, and only then typed. The server is a referee, not a guesser.
Before running GROUP BY, the student circles the rows that belong together. A wrong count usually shows up here.
SQL queries are 7 of the 30 practical marks. The same two-table habit serves both examinations.
Carry on with the 15 SQL queries of the IP practical file, the full IP practice paper, IP MCQs, or the important questions of all four units. If your subject is 083, the list is different: see Class 12 CS SQL questions.
One to one, at your own timing
An SQL doubt is easiest to settle on a live table with one person watching. So Unit 2 is taught personalised one to one, on days and at hours you fix. You may begin with a priority demo, whose fee is adjusted in your first month if you enrol, or with a free demo class. Billing is monthly, admission costs nothing, and you can stop when any month ends.
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
You will not be asked to learn queries by heart. The aim is that a new table in the exam looks like an old one with different names. Your fee is shown on this page in your own currency.
Studying outside India?
CBSE schools in the Gulf and elsewhere use the same 065 paper and the same function list. Pick an evening or a weekend morning where you live.
| 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 |
If MySQL is not on your laptop yet, installing it can be the first thing we do together. Until then the class runs on the teacher's screen.
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 Informatics Practices series, grouped by what you need.
CBSE Class 12 Computer Science (083): Class 12 CS viva questions Class 12 CS sample paper practice Class 12 CS project with source code Class 12 CS 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 practical file programs Python programs for Class 11 CS and IP
Questions about Unit 2
Database Query using SQL is Unit 2 of CBSE Informatics Practices (065) and carries 25 of the 70 theory marks in 2026-27, the same as pandas with data visualization. In the sample paper these marks come from Questions 2, 6, 9, 11, 14, 17, 19, 21, 26, 31, 32, 34 and 37. SQL queries are also 7 of the 30 practical marks.
Math: POWER, ROUND and MOD. Text: UCASE or UPPER, LCASE or LOWER, MID or SUBSTRING or SUBSTR, LENGTH, LEFT, RIGHT, INSTR, LTRIM, RTRIM and TRIM. Date: NOW, DATE, MONTH, MONTHNAME, YEAR, DAY and DAYNAME. Aggregate: MAX, MIN, AVG, SUM and COUNT, including COUNT(*). Nothing else is listed for 2026-27.
GROUP BY puts rows with the same value together and returns one row for each group, normally with an aggregate function. ORDER BY only arranges the rows of the result and removes none of them. When both are used, GROUP BY comes first and ORDER BY is the last clause.
WHERE tests single rows before they are grouped and cannot contain an aggregate function. HAVING tests groups after GROUP BY and usually contains one, for example HAVING COUNT(*) = 2. A query may have both: WHERE removes unwanted rows, then HAVING removes unwanted groups.
Yes, but only one kind is named: working with two tables using equi-join. You write both tables after FROM and put the equality of the common column in WHERE. Natural join and outer joins are not listed in 065. Natural join belongs to the 083 Computer Science syllabus.
COUNT(*) counts the rows, whatever they hold. COUNT(column) counts only the rows in which that column is not NULL. On a table of nine rows with two NULLs in Photos, COUNT(*) is 9 and COUNT(Photos) is 7. SUM and AVG also leave NULL out.
None in MySQL. They are three names for one function, and the syllabus lists all three. Each takes the string, a starting position counted from 1, and how many characters to return. If the third value is missing, the rest of the string is returned.
They answer different questions. MONTH() returns 1 to 12, which is useful for comparing, as in WHERE MONTH(LDate) = 11. MONTHNAME() returns the full name, which is useful for display. DAY() and DAYNAME() differ in the same way: one gives the date of the month, the other the weekday.
The official marking scheme for 2026-27 prints the headings with the values for table outputs, for example DAY(DOB) and YEAR(DOB). Copy the expression as it is in the SELECT line and write the values under it. It also helps you check that you have the right number of columns.
Keywords and function names are not, so select and SELECT both work. Writing keywords in capitals makes the answer easier to read. Table and column names should be copied from the question. Text inside quotes is data, so copy it as the table shows it.
Make two small tables of your own with about eight rows and a common column, and put one NULL in a number column. Write three queries a day: one with a function, one with GROUP BY, one equi-join. Predict the result on paper first. A wrong prediction teaches more than a right query.
Yes. Classes are live and personalised, so a student may work only on Unit 2 and stop after it. Times are chosen by you. Start with a priority demo, a full class of about 45 to 60 minutes with a written skill report, or with the free demo class. Billing is monthly.
Start
The free demo class begins with a table and a question in plain English. You write the query, and the teacher shows you how MySQL reads it.
A priority demo is a complete class at the hour you pick. It goes through functions, grouping and a join, marks one answer fully, and ends with a written skill report. If you join, its fee is counted towards the first month.
Not sure where Unit 2 sits in your year? See the IP syllabus and paper pattern.
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