Skip to main content
Chapter 9 of 13
NCERT Solutions

Structured Query a Language (SQL)

CBSE · Class 12 · Computer Science

NCERT Solutions for Structured Query a Language (SQL) — CBSE Class 12 Computer Science.

50 questions96 flashcards5 concepts

Interactive on Super Tutor

Studying Structured Query a Language (SQL)? 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

A diagram illustrating how SQL interacts with various Relational Database Management Systems (RDBMS) like MySQL, Oracle, PostgreSQL, and SQL Server, showing SQL as the common language for data access
Super Tutor

This is just one of 17+ visuals inside Super Tutor's Structured Query a Language (SQL) chapter

Explore the full set
54 Questions Solved · 1 Section

27 worked solutions below. Unlock all 54 free in Super Tutor

EXERCISE

1(a)Define RDBMS. Name any two RDBMS software.Show solution
RDBMS stands for Relational Database Management System. It is a database management system that stores data in the form of related tables (relations) and allows us to create, store, retrieve, and manipulate data.

Two RDBMS software examples are MySQL and Oracle.

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

1(b)What is the purpose of the following clauses in a select statement?Show solution
- ORDER BY clause is used to display the result in a specified order, usually ascending by default; with DESC, it shows descending order.
- GROUP BY clause is used to group rows having the same values in a column so that aggregate functions like COUNT, SUM, MAX, MIN, AVG can be applied on each group.

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

1(c)Site any two differences between Single Row Functions and Aggregate Functions.Show solution
Any two differences are:

1. Single Row Functions work on one row at a time and return one result per row; Aggregate Functions work on a group of rows and return one result for the whole group.
2. Single Row Functions can be used in SELECT, WHERE, and ORDER BY clauses; Aggregate Functions are used in the SELECT clause only.

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

1(d)What do you understand by Cartesian Product?Show solution
Cartesian Product is an operation on two relations that combines every tuple of the first relation with every tuple of the second relation. The result contains all possible pairs of rows. Its cardinality is the product of the cardinalities of the two relations, and its degree is the sum of their degrees.

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

1(e)Differentiate between the following statements:Show solution
i) ALTER and UPDATE
- ALTER changes the structure/schema of a table, such as adding/removing/modifying columns or constraints.
- UPDATE changes the data/values stored in existing records.

ii) DELETE and DROP
- DELETE removes records/rows from a table; the table remains.
- DROP removes the table or database permanently from the system.

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

1(f)Write the name of the functions to perform the following operations:Show solution
The required SQL functions are:

1. To display the day like “Monday”, “Tuesday” from a date: DAYNAME()
2. To display a specified number of characters from a particular position: MID() / SUBSTRING() / SUBSTR()
3. To display the name of the month: MONTHNAME()
4. To display a name in capital letters: UCASE() / UPPER()

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

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

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

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

2(b)SELECT ROUND(342.9234,-1);Show solution
`ROUND(342.9234, -1)` rounds the number to the nearest 10.

So, 342.9234340342.9234 \approx 340

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

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

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

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

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

2(d)SELECT YEAR("1979/11/26"),
MONTH("1979/11/26"),
DAY("1979/11/26"),
MONTHNAME("1979/11/26");
Show solution
For the date `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

2(e)SELECT LEFT("INDIA",3),
RIGHT("Computer Science",4),
MID("Informatics",3,4),
SUBSTR("Practices",3);
Show solution
Evaluate each function:

- `LEFT("INDIA",3)` = IND
- `RIGHT("Computer Science",4)` = erSc
- `MID("Informatics",3,4)` = characters from position 3 for length 4 = form
- `SUBSTR("Practices",3)` = substring from position 3 till end = actices

So the output is IND, erSc, form, actices.

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

3Consider the following MOVIE table and write the SQL queries based on it.Show solution

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

3(a)Display all the information from the Movie table.Show solution

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

3(b)List business done by the movies showing only MovieID, MovieName and Total_Earning. Total_Earning to be calculated as the sum of ProductionCost and BusinessCost.Show solution

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

3(c)List the different categories of movies.Show solution

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

3(d)Find the net profit of each movie showing its MovieID, MovieName and NetProfit. Net Profit is to be calculated as the difference between Business Cost and Production Cost.Show solution

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

3(e)List MovieID, MovieName and Cost for all movies with ProductionCost greater than 10,000 and less than 1,00,000.Show solution

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

3(f)List details of all movies which fall in the category of comedy or action.Show solution

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

3(g)List details of all movies which have not been released yet.4. Suppose your school management has decided to conduct cricket matches between students of Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team Titan, Team Rockers, Team Magnet and Team Hurricane. During summer vacations, various matches will be conducted between these teams. Help your sports teacher to do the following:- a) Create a database “Sports”.Show solution

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

4(b)Create a table “TEAM” with following considerations:Show solution

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

4(c)Using table level constraint, make TeamID as the primary key.Show solution

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

4(d)Show the structure of the table TEAM using a SQL statement.Show solution

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

4(e)As per the preferences of the students four teams were formed as given below. Insert these four rows in TEAM table:Show solution

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

4(f)Show the contents of the table TEAM using a DML statement.Show solution

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

4(g)Now create another table MATCH\_DETAILS and insert data as shown below. Choose appropriate data types and constraints for each attribute.Show solution

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

5Using the sports database containing two relations (TEAM, MATCH\_DETAILS) and write the queries for the following:Show solution

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

5(a)Display the MatchID of all those matches where both the teams have scored more than 70.Show solution

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

5(b)Display the MatchID of all those matches where FirstTeam has scored less than 70 but SecondTeam has scored more than 70.
5(c)Display the MatchID and date of matches played by Team 1 and won by it.
5(d)Display the MatchID of matches played by Team 2 and not won by it.
5(e)Change the name of the relation TEAM to T_DATA. Also change the attributes TeamID and TeamName to T_ID and T_NAME respectively.
6A shop called Wonderful Garments who sells school uniforms maintains a database SCHOOLUNIFORM as shown below. It consisted of two relations - UNIFORM and COST. They made UniformCode as the primary key for UNIFORM relations. Further, they used UniformCode and Size to be composite keys for COSTrelation. By analysing the database schema and database state, specify SQL queries to rectify the following anomalies.
6(a)M/S Wonderful Garments also keeps handkerchiefs of red colour, medium size of Rs. 100 each.
6(b)INSERT INTO COST (UCode, Size, Price) values (7, 'M',100);
6(c)Further, they should be able to assign a new UCode to an item only if it has a valid UName. Write a query to add appropriate constraints to the SCHOOLUNIFORM database.
6(d)Add the constraint so that the price of an item is always greater than zero.
7Consider the following table named "Product", showing details of products being sold in a grocery shop.
7(a)Create the table Product with appropriate data types and constraints.
7(b)Identify the primary key in Product.
7(c)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.
7(d)Add a new column Discount to the table Product.
7(e)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.
7(f)Increase the price by 12 per cent for all the products manufactured by Dove.
7(g)Display the total number of products manufactured by each manufacturer.
7(h)SELECT PName, avg(UPrice) FROM Product GROUP BY PName;
7(i)SELECT DISTINCT Manufacturer FROM Product;
7(j)SELECT COUNT (DISTINCT PName) FROM Product;
7(k)SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;
8Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following:
8(a)Add a new column Discount in the INVENTORY table.
8(b)Set appropriate discount values for all cars keeping in mind the following:
8(c)Display the name of the costliest car with fuel type "Petrol".
8(d)Calculate the average discount and total discount available on Baleno cars.
8(e)List the total number of cars having no discount.

27 more solved questions in Structured Query a Language (SQL)

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 Structured Query a Language (SQL) for CBSE Class 12 Computer Science?
Structured Query a Language (SQL) 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 Structured Query a Language (SQL) — CBSE Class 12 Computer Science?
Understand the core concepts first, then work through the 50 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 Structured Query a Language (SQL) Class 12 Computer Science?
This page has free step-by-step NCERT Solutions for every exercise question in Structured Query a Language (SQL) (CBSE Class 12 Computer Science) — 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 Structured Query a Language (SQL) chapter — for free.

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