MySQL Master Study Portal

Class XII Informatics Practices | Board Exam Resource

1. The Mandatory Clause Order

SELECT ➤ FROM ➤ WHERE ➤ GROUP BY ➤ HAVING ➤ ORDER BY

2. Variations of SELECT Command

-- 1. Selection with Condition
SELECT column_name, function_name()
FROM table_name
WHERE condition;

-- 2. Selection with Sorting
SELECT column_name, function_name()
FROM table_name
ORDER BY column_name ASC|DESC;

-- 3. Selection with Grouping
SELECT column_name, function_name()
FROM table_name
GROUP BY column_name
HAVING condition;

-- 4. Joining two tables (Equi-Join)
SELECT column_name, function_name()
FROM table_1, table_2
WHERE table_1.pk = table_2.fk;
Important Rule: The column name specified with GROUP BY must also be included in the SELECT statement list to display meaningful groups.

3. Key Concept: Handling NULL Values

Exam Tip

Whenever a question mentions "not assigned," "unknown," "not mentioned," or "missing," you MUST use the IS NULL operator.

SELECT * FROM Employees WHERE Department IS NULL; -- Correct
SELECT * FROM Employees WHERE Department = NULL; -- Returns Nothing

4. Exam Prep Checklist (Functions)

Math: MOD(), POWER(), ROUND(), TRUNCATE()
String: UPPER(), LOWER(), LENGTH(), LEFT(), RIGHT(), INSTR(), TRIM()
Date: NOW(), DATE(), MONTHNAME(), YEAR(), DAYNAME()
Aggregates: SUM(), AVG(), COUNT(), MAX(), MIN()

4. Built-in Function Practice (Query Based)

To calculate the square of 15.
SELECT POW(15, 2);
To round the number 456.789 to the nearest integer.
SELECT ROUND(456.789);
To display the position of first occurrence of 'com' in the string 'mycommercial.com'.
SELECT INSTR('mycommercial.com', 'com');
To display the name of the day for the date '2024-11-07'.
SELECT DAYNAME('2024-11-07');
To display the current date and time.
SELECT NOW();
To display the total number of characters in the string "Database Systems".
SELECT LENGTH("Database Systems");
To display the remainder when 25 is divided by 7.
SELECT MOD(25, 7);
To reduce 1234.567 to 2 decimal places without rounding.
SELECT TRUNCATE(1234.567, 2);
To display the first three characters of the string "Informatics".
SELECT LEFT("Informatics", 3);
To display the last four characters of the string "ComputerScience".
SELECT RIGHT("ComputerScience", 4);
To display the current month name for the date '2026-03-23'.
SELECT MONTHNAME('2026-03-23');

5. Fresh Practice Questions (Functions)

Q1. Display the remainder when 25 is divided by 7.
SELECT MOD(25, 7);
Q2. Reduce 1234.567 to 2 decimal places without rounding.
SELECT TRUNCATE(1234.567, 2);
Q3. Find the starting position of 'Learning' in 'Machine Learning'.
SELECT INSTR('Machine Learning', 'Learning');
Q4. Display the name of the month for the date '2026-08-15'.
SELECT MONTHNAME('2026-08-15');
Q5. Display the first three characters of the string "Informatics".
SELECT LEFT("Informatics", 3);
Q6. Calculate the value of 5 raised to the power of 3.
SELECT POW(5, 3);

6. Pattern Matching & Aggregates

Aggregate Function Behavior

Function Task Null Treatment
COUNT(*) Counts all rows Includes NULLs
COUNT(column) Counts specific values Excludes NULLs
AVG(column) Calculates Average Ignores NULLs

LIKE Operator Patterns

SELECT * FROM Products WHERE PName LIKE 'S%'; -- Starts with 'S'
SELECT * FROM Products WHERE PName LIKE '%e'; -- Ends with 'e'
SELECT * FROM Products WHERE PName LIKE '__a%'; -- 'a' at 3rd position
Back to Home back to portal