Informatics PracticesClass 12Querying and SQL

Querying and SQL | Class 12 Informatics Practices Notes

By ConceptScroll Team · Published on 17 July 2026 · 5 min read

Querying and SQL – this guide gives you a concise, exam-ready overview of Querying and SQL from Class 12 Informatics Practices, written by ConceptScroll editors and reviewed against the latest NCERT textbook.

1.2.1 Single Row Functions

Single Row Functions in SQL operate on individual rows and return a single value for each row processed. They are essential for transforming and manipulating data within queries. These functions are classified into three categories: Numeric (Math) functions, String functions, and Date and Time functions. Numeric functions like POWER(), ROUND(), and MOD() perform mathematical operations such as exponentiation, rounding numbers to specified decimal places, and calculating remainders. String functions manipulate text data by changing case, extracting substrings, trimming spaces, and finding positions of characters. Date and Time functions extract components like day, month, year, or return current date/time. These functions enable precise data formatting and calculations directly within SQL queries, enhancing data analysis and reporting.

📊 Diagram: Table 1.5 lists the syntax, description, and examples of numeric functions POWER(), ROUND(), and MOD().

🧪 Activity: Activity 1.1: Write SQL queries using SALE table to display InvoiceNo and commission rounded to zero decimal places and to display sales with payment mode as credit card.

🔗 Connection: Leads to detailed study of String Functions and Date and Time Functions in subsequent subsections.

Frequently asked questions

1. Answer the following questions: a) Define RDBMS. Name any two RDBMS software. b) What is the purpose of the following clauses in a select statement? i) ORDER BY ii) HAVING c) Site any two differences between Single_row functions and Aggregate functions. d) What do you understand by Cartesian Product? e) Write the name of the functions to perform the following operations: i) To display the day like “Monday”, “Tuesday”, from the date when India got independence. ii) To display the specified number of characters from a particular position of the given string. iii) To display the name of the month in which you were born. iv) To display your name in capital letters.

a) RDBMS (Relational Database Management System) is a database management system based on the relational model that stores data in tables (relations) consisting of rows and columns. Examples include MySQL and Oracle.

b) Purpose of clauses: i) ORDER BY: Used to sort the result set of a query by one or more columns either in ascending or descending order. ii) HAVING: Used to filter groups created by GROUP BY clause based on a condition.

c) Differences between Single_row functions and Aggregate f

2. Write the output produced by the following SQL commands: a) SELECT POW(2,3); b) SELECT ROUND(123.2345, 2), ROUND(342.9234,-1); c) SELECT LENGTH("Informatics Practices"); d) SELECT YEAR("1979/11/26"), MONTH("1979/11/26"), DAY("1979/11/26"), MONTHNAME("1979/11/26"); e) SELECT LEFT("INDIA",3), RIGHT("Computer Science",4); f) SELECT MID("Informatics",3,4), SUBSTR("Practices",3);

a) POW(2,3) returns 8 because 2 raised to the power 3 is 8.

b) ROUND(123.2345, 2) returns 123.23 (rounded to 2 decimal places). ROUND(342.9234, -1) rounds to nearest 10, returns 340.

c) LENGTH("Informatics Practices") returns 20 (number of characters including space).

d) YEAR("1979/11/26") returns 1979. MONTH("1979/11/26") returns 11. DAY("1979/11/26") returns 26. MONTHNAME("1979/11/26") returns 'November'.

e) LEFT("INDIA",3) returns 'IND'. RIGHT("Computer Science",4) returns

3. Consider the following table named "Product", showing details of products being sold in a grocery shop. | PCode | PName | UPrice | Manufacturer | | --- | --- | --- | --- | | P01 | Washing Powder | 120 | Surf | | P02 | Tooth Paste | 54 | Colgate | | P03 | Soap | 25 | Lux | | P04 | Tooth Paste | 65 | Pepsodant | | P05 | Soap | 38 | Dove | | P06 | Shampoo | 245 | Dove | a) Write SQL queries for the following: i. Create the table Product with appropriate data types and constraints. ii. Identify the primary key in Product. iii. List the Product Code, Product name and price in descending order of their product name. If PName is the same then display the data in ascending order of price. iv. Add a new column Discount to the table Product. v. Calculate the value of the discount in the table Product as 10 per cent of the UPrice for all those products where the UPrice is more than 100, otherwise the discount will be 0. vi. Increase the price by 12 per cent for all the products manufactured by Dove. vii. Display the total number of products manufactured by each manufacturer. b) Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product: i. SELECT PName, Average(UPrice) FROM Product GROUP BY Pname; ii. SELECT DISTINCT Manufacturer FROM Product; iii. SELECT COUNT(DISTINCT PName) FROM Product; iv. SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;

a) SQL Queries:

i. CREATE TABLE Product ( PCode VARCHAR(5) PRIMARY KEY, PName VARCHAR(50), UPrice INT, Manufacturer VARCHAR(50) );

ii. Primary key is PCode.

iii. SELECT PCode, PName, UPrice FROM Product ORDER BY PName DESC, UPrice ASC;

iv. ALTER TABLE Product ADD COLUMN Discount DECIMAL(5,2);

v. UPDATE Product SET Discount = CASE WHEN UPrice > 100 THEN UPrice * 0.10 ELSE 0 END;

vi. UPDATE Product SET UPrice = UPrice * 1.12 WHERE Manufacturer = 'Dove';

vii. SELECT Manufacturer, COU

4. Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following: a) Add a new column Discount in the INVENTORY table. b) Set appropriate discount values for all cars keeping in mind the following: (i) No discount is available on the LXI model. (ii) VXI model gives a 10% discount. (iii) A 12% discount is given on cars other than LXI model and VXI model. c) Display the name of the costliest car with fuel type "Petrol". d) Calculate the average discount and total discount available on Car4. e) List the total number of cars having no discount.

a) ALTER TABLE INVENTORY ADD COLUMN Discount DECIMAL(5,2);

b) UPDATE INVENTORY SET Discount = CASE WHEN Model = 'LXI' THEN 0 WHEN Model = 'VXI' THEN Price 0.10 ELSE Price 0.12 END;

c) SELECT CarName FROM INVENTORY WHERE FuelType = 'Petrol' ORDER BY Price DESC LIMIT 1;

d) SELECT AVG(Discount) AS AverageDiscount, SUM(Discount) AS TotalDiscount FROM INVENTORY WHERE CarName = 'Car4';

e) SELECT COUNT(*) FROM INVENTORY WHERE Discount = 0;

Ready to ace this chapter?

Get the full Querying and SQL chapter — interactive notes, diagrams, worked solutions, polls and a free practice quiz — in the ConceptScroll app.

Open in ConceptScroll →

Study smarter with ConceptScroll

Daily NCERT-aligned reels, AI doubt solving and chapter quizzes — all free.

Start learning free
#cbse notes#class 12#informatics practices#ncert

Continue reading