Skip to main content
Chapter 1 of 7
NCERT Solutions

Querying and SQL Functions

CBSE · Class 12 · Informatics Practices

NCERT Solutions for Querying and SQL Functions — CBSE Class 12 Informatics Practices.

111 questions84 flashcards5 concepts

Interactive on Super Tutor

Studying Querying and SQL Functions? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for ncert solutions and more.

1,000+ Class 12 students started this chapter today

42 Questions Solved · 1 Section

21 worked solutions below. Unlock all 42 free in Super Tutor

Exercise

1aDefine RDBMS. Name any two RDBMS software.Show solution
An RDBMS is a Relational Database Management System. It stores data in the form of related tables (relations) and manages relationships among them.

Two examples are MySQL and Oracle.

Not sure why a step works? check your working in Super Tutor

1b(i)What is the purpose of the following clauses in a select statement?Show solution
i) ORDER BY: It is used to sort the records in a query result in ascending or descending order.

ii) HAVING: It is used to apply conditions on grouped records when using GROUP BY.

Not sure why a step works? check your working in Super Tutor

1cSite any two differences between Single_row functions and Aggregate functions.Show solution
Any two differences are:

1. Single row functions work on a single row at a time, while aggregate functions work on a group of rows.
2. Single row functions return one result per row, while aggregate functions return one result for the whole group.
3. Single row functions can be used in SELECT, WHERE, and ORDER BY, while aggregate functions are used in the SELECT clause only.

Not sure why a step works? check your working in Super Tutor

1dWhat do you understand by Cartesian Product?Show solution
Cartesian Product is an operation that combines tuples from two relations and produces all possible pairs of rows from the two tables, regardless of whether the values match or not.

If one table has mm rows and the other has nn rows, the result has m×nm \times n rows.

Not sure why a step works? check your working in Super Tutor

1e(i)Write the name of the functions to perform the following operations:Show solution
To display the day like Monday, Tuesday, etc., from a date, the function used is DAYNAME().

Not sure why a step works? check your working in Super Tutor

1e(ii)Write the name of the functions to perform the following operations:Show solution
To display the specified number of characters from a particular position of a string, the function used is SUBSTRING(). The chapter also mentions MID() and SUBSTR() for the same purpose.

Not sure why a step works? check your working in Super Tutor

1e(iii)Write the name of the functions to perform the following operations:Show solution
To display the name of the month in which you were born, the function used is MONTHNAME().

Not sure why a step works? check your working in Super Tutor

1e(iv)Write the name of the functions to perform the following operations:Show solution
To display your name in capital letters, the function used is UPPER(). The chapter also gives UCASE() as an equivalent.

Not sure why a step works? check your working in Super Tutor

2aSELECT POW(2,3);Show solution
`POW(2,3)` means 232^3.

2×2×2=82 \times 2 \times 2 = 8

So the output is 8.

Not sure why a step works? check your working in Super Tutor

2bSELECT ROUND(123.2345, 2), ROUND(342.9234,-1);Show solution
- `ROUND(123.2345, 2)` rounds to 123.23.
- `ROUND(342.9234, -1)` rounds to the nearest tens, so it becomes 340.

So the output is 123.23, 340.

Not sure why a step works? check your working in Super Tutor

2cSELECT LENGTH("Informatics Practices");Show solution
`LENGTH("Informatics Practices")` counts all characters including the space.

- Informatics = 11
- space = 1
- Practices = 9

Total = 11+1+9=2111 + 1 + 9 = 21

So the output is 21.

Not sure why a step works? check your working in Super Tutor

2dSELECT YEAR("1979/11/26"),
MONTH("1979/11/26"),
DAY("1979/11/26"),

MONTHNAME("1979/11/26");
Show solution
From `"1979/11/26"`:

- `YEAR()` = 1979
- `MONTH()` = 11
- `DAY()` = 26
- `MONTHNAME()` = November

So the output is 1979, 11, 26, November.

Not sure why a step works? check your working in Super Tutor

2eSELECT LEFT("INDIA",3), RIGHT("Computer Science",4);Show solution
- `LEFT("INDIA",3)` gives IND.
- `RIGHT("Computer Science",4)` gives ence.

So the output is IND, ence.

The printed text in the question pairs this with the values from the chapter-style format; the correct result from the SQL command is IND, ence.

Not sure why a step works? check your working in Super Tutor

2fSELECT MID("Informatics",3,4), SUBSTR("Practices",3);Show solution
- `MID("Informatics",3,4)` starts from position 3 and takes 4 characters: form.
- `SUBSTR("Practices",3)` starts from position 3 till the end: actices.

So the output is form, actices.

Not sure why a step works? check your working in Super Tutor

3a(i)Write SQL queries for the following:Show solution
i) `CREATE TABLE Product (PCode VARCHAR(3) PRIMARY KEY, PName VARCHAR(30), UPrice NUMERIC(6,2), Manufacturer VARCHAR(20));`

ii) The primary key is PCode.

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

iv) `ALTER TABLE Product ADD Discount NUMERIC(6,2);`

v) `UPDATE Product SET Discount = IF(UPrice > 100, 10/100*UPrice, 0);`

vi) `UPDATE Product SET UPrice = UPrice + 12/100*UPrice WHERE Manufacturer = 'Dove';`

vii) `SELECT Manufacturer, COUNT(*) FROM Product GROUP BY Manufacturer;`

Not sure why a step works? check your working in Super Tutor

3a(ii)Write SQL queries for the following:Show solution
To list the Product Code, Product name, and price in descending order of product name, and if `PName` is the same then in ascending order of price, the correct query is:

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

Not sure why a step works? check your working in Super Tutor

3a(iii)Write SQL queries for the following:Show solution
i) `SELECT PName, AVG(UPrice) FROM Product GROUP BY PName;`

ii) The outputs would be:
- For Tooth Paste: average of 54 and 65 = 59.5
- For Soap: average of 25 and 38 = 31.5
- For Washing Powder: 120
- For Shampoo: 245

So the result is grouped by `PName` with the average price of each group.

Not sure why a step works? check your working in Super Tutor

3a(iv)Write SQL queries for the following:Show solution
i) `SELECT PName, AVG(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;`

Not sure why a step works? check your working in Super Tutor

3a(vii)Write SQL queries for the following:Show solution
The chapter’s query for average unit price by product name is:

`SELECT PName, AVG(UPrice) FROM Product GROUP BY PName;`

Not sure why a step works? check your working in Super Tutor

3b(i)Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product:Show solution
Using `GROUP BY PName` and `AVG(UPrice)`:

- Tooth Paste: (54+65)/2=59.5(54 + 65) / 2 = 59.5
- Soap: (25+38)/2=31.5(25 + 38) / 2 = 31.5
- Washing Powder: 120120
- Shampoo: 245245

So the output contains these grouped averages.

Not sure why a step works? check your working in Super Tutor

3b(ii)Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product:Show solution
`SELECT DISTINCT Manufacturer FROM Product;` returns each manufacturer only once.

The distinct manufacturers are Surf, Colgate, Lux, Pepsodant, Dove. Order may vary, but these are the values.

Not sure why a step works? check your working in Super Tutor

3b(iii)Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product:
3b(iv)Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product:
4aUsing the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4b(i)Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4b(ii)Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4b(iii)Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4cUsing the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4dUsing the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
4eUsing the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
5aWrite SQL queries for the following:
5bWrite SQL queries for the following:
5cWrite SQL queries for the following:
5dWrite SQL queries for the following:
5eWrite SQL queries for the following:
5fWrite SQL queries for the following:
5gWrite SQL queries for the following:
5hWrite SQL queries for the following:
5iWrite SQL queries for the following:
5jWrite SQL queries for the following:
5kWrite SQL queries for the following:
5lWrite SQL queries for the following:

21 more solved questions in Querying and SQL Functions

Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Querying and SQL Functions for CBSE Class 12 Informatics Practices?
Querying and SQL Functions covers several key topics that are frequently asked in CBSE Class 12 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Querying and SQL Functions — CBSE Class 12 Informatics Practices?
Understand the core concepts first, then work through the 111 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Querying and SQL Functions Class 12 Informatics Practices?
This page has free step-by-step NCERT Solutions for every exercise question in Querying and SQL Functions (CBSE Class 12 Informatics Practices) — written the way examiners award marks: given, formula, working, answer.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Querying and SQL Functions chapter — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 12 Informatics Practices.