0% found this document useful (0 votes)
253 views

Chapter 9 - Structured Query Language (SQL) - NCERT Solutions For Class 12 Computer Science Code 083 CB

Uploaded by

naga06557
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
253 views

Chapter 9 - Structured Query Language (SQL) - NCERT Solutions For Class 12 Computer Science Code 083 CB

Uploaded by

naga06557
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

STUDY MATERIAL LOGIN JOIN NOW

Home / Class 12 - NCERT Computer Science Solutions / Structured Query Language (SQL)

Chapter 9
Structured Query Language (SQL)
Class 12 - NCERT Computer Science Solutions

Bengaluru to New Delhi India to Thailand

from Bengaluru from India

from Rs11,532 from Rs13,794


View Now View Now

Exercise

Question 1(a)

Define RDBMS. Name any two RDBMS software.

Answer

An RDBMS is a database management system based on the relational model,


storing data in tables of rows and columns, enabling data retrieval, manipulation,
and relationships through SQL queries. Two examples of RDBMS software are
MySQL and Oracle Database.

Question 1(b)
What is the purpose of the following clauses in a select statement?

(i) ORDER BY

(ii) GROUP BY

Answer

(i) ORDER BY clause is used to sort the result set of a SELECT statement either
in ascending (default) or descending order based on one or more columns. The
ASC keyword is used for ascending order, and the DESC keyword is used for
descending order.

(ii) GROUP BY clause is used to group rows that have the same values in
specified columns into summary rows. It is commonly used with aggregate
functions (e.g., SUM, COUNT, AVG) to perform calculations on grouped data.

Question 1(c)

Site any two differences between Single Row Functions and Aggregate Functions.

Answer

Two differences between Single Row Functions and Aggregate Functions are:

Single Row Functions Aggregate Functions

Single row functions operate on Aggregate functions operate on groups


individual rows and return a single of rows and return a single result for
value per row. each group.

It can be used in SELECT, WHERE, It can be used in the SELECT clause


and ORDER BY clause. only.

Question 1(d)

What do you understand by Cartesian Product?


Answer

The Cartesian Product is an operation that combines tuples from two relations. It
results in all possible pairs of rows from the two input relations, regardless of
whether they have matching values on common attributes. This operation is
denoted by the cross join symbol (×) in SQL.

Question 1(e)

Differentiate between the following statements:

(i) ALTER and UPDATE

(ii) DELETE and DROP

Answer

(i) Differences between ALTER and UPDATE statements:

ALTER statement UPDATE statement

The ALTER statement is used to


modify the structure of database The UPDATE statement is used to
objects, such as tables, views, or modify the existing data in a table.
schemas.

It can be used to add, modify, or It is used to change the values of one or


drop columns, constraints, or more columns in a table based on
indexes in a table. specified conditions.

For example: ALTER TABLE For example: UPDATE Employees SET

Chapter 4 Employees ADD Email Email = '[email protected]' WHERE


Queue
Search by lesson title VARCHAR(255); EmployeeID = 101;

Chapter 5 CONTENTS
Sorting (ii) Differences between DELETE and DROP statements:
Exercise
Chapter 6
Chapter 6
Searching
DELETE statement DROP statement
Chapter 7
The DELETE statement is used to The DROP statement is used to
Understanding Data
remove one or more rows from a remove entire database objects, such
Chapter 8
table based on specified as tables, views, indexes, or schemas,
Database Concepts
conditions. from the database.
Chapter 9
Structured Query Language (SQL) It deletes specific rows of data
It deletes the entire object along with its
Chapter 10
while keeping the table structure
structure and data.
Computer Networks intact.

Chapter 11 For example, DELETE FROM


Data Communication
Employees WHERE Department = For example, DROP TABLE Products;
Chapter 12
'Marketing';
Security Aspects

Question 1(f)

Write the name of the functions to perform the following operations:

1. To display the day like 'Monday', 'Tuesday', from the date when India got
independence.
2. To display the specified number of characters from a particular position of the
given string.
3. To display the name of the month in which you were born.
4. To display your name in capital letters.

Answer

1. DAYNAME("1947-08-15")
2. SUBSTRING(string, pos, n)
3. MONTHNAME("yyyy-mm-dd")
4. UPPER('YourName')
Question 2

Write the output produced by the following SQL statements:

(a) SELECT POW(2, 3);

(b) SELECT 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("ComputerScience", 4), MID("Informatics",


3, 4), SUBSTR("Practices", 3);

Answer

(a)

Output

+-----------+
| POW(2, 3) |
+-----------+
| 8 |
+-----------+

(b)

Output

+---------------------+
| ROUND(342.9234, -1) |
+---------------------+
| 340 |
+---------------------+
(c)

Output

+---------------------------------+
| LENGTH("Informatics Practices") |
+---------------------------------+
| 21 |
+---------------------------------+

(d)

Output

+--------------------+---------------------+-------------------+-----------
| YEAR("1979/11/26") | MONTH("1979/11/26") | DAY("1979/11/26") | MONTHNAME(
+--------------------+---------------------+-------------------+-----------
| 1979 | 11 | 26 | November
+--------------------+---------------------+-------------------+-----------

(e)

Output

+------------------+-----------------------------+-------------------------
| LEFT("INDIA", 3) | RIGHT("ComputerScience", 4) | MID("Informatics", 3, 4)
+------------------+-----------------------------+-------------------------
| IND | ence | form
+------------------+-----------------------------+-------------------------

Question 3

Consider the following MOVIE table and write the SQL queries based on it.
MovieID MovieName Category ReleaseDate ProductionCost

001 Hindi_Movie Musical 2018-04-23 124500

002 Tamil_Movie Action 2016-05-17 112000

003 English_Movie Horror 2017-08-06 245000

004 Bengali_Movie Adventure 2017-01-04 72000

005 Telugu_Movie Action - 100000

006 Punjabi_Movie Comedy - 30500

(a) Display all the information from the Movie table.

(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.

(c) List the different categories of movies.

(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.

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

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

(g) List details of all movies which have not been released yet.

Answer

(a)
SELECT * FROM Movie;

Output

+---------+---------------+-----------+-------------+----------------+-----
| MOVIEID | MOVIENAME | CATEGORY | RELEASEDATE | PRODUCTIONCOST | BUSI
+---------+---------------+-----------+-------------+----------------+-----
| 1 | Hindi_Movie | Musical | 2018-04-23 | 124500 |
| 2 | Tamil_Movie | Action | 2016-05-17 | 112000 |
| 3 | English_Movie | Horror | 2017-08-06 | 245000 |
| 4 | Bengali_Movie | Adventure | 2017-01-04 | 72000 |
| 5 | Telugu_Movie | Action | NULL | 100000 |
| 6 | Punjabi_Movie | Comedy | NULL | 30500 |
+---------+---------------+-----------+-------------+----------------+-----

(b)

SELECT MovieID, MovieName, (ProductionCost + BusinessCost) AS Total_Earning


FROM Movie
WHERE ReleaseDate IS NOT NULL;

Output

+---------+---------------+---------------+
| MovieID | MovieName | Total_Earning |
+---------+---------------+---------------+
| 1 | Hindi_Movie | 254500 |
| 2 | Tamil_Movie | 230000 |
| 3 | English_Movie | 605000 |
| 4 | Bengali_Movie | 172000 |
+---------+---------------+---------------+

(c)
SELECT DISTINCT Category FROM MOVIE;

Output

+-----------+
| Category |
+-----------+
| Musical |
| Action |
| Horror |
| Adventure |
| Comedy |
+-----------+

(d)

SELECT MovieID, MovieName, BusinessCost - ProductionCost AS NetProfit


FROM Movie
WHERE ReleaseDate IS NOT NULL;

Output

+---------+---------------+-----------+
| MovieID | MovieName | NetProfit |
+---------+---------------+-----------+
| 1 | Hindi_Movie | 5500 |
| 2 | Tamil_Movie | 6000 |
| 3 | English_Movie | 115000 |
| 4 | Bengali_Movie | 28000 |
+---------+---------------+-----------+

(e)

SELECT MovieID, MovieName, ProductionCost AS Cost


FROM MOVIE
WHERE ProductionCost > 10000 AND ProductionCost < 100000;
Output

+---------+---------------+-------+
| MovieID | MovieName | Cost |
+---------+---------------+-------+
| 4 | Bengali_Movie | 72000 |
| 6 | Punjabi_Movie | 30500 |
+---------+---------------+-------+

(f)

SELECT * FROM MOVIE


WHERE Category = 'Comedy' OR Category = 'Action';

Output

+---------+---------------+----------+-------------+----------------+------
| MOVIEID | MOVIENAME | CATEGORY | RELEASEDATE | PRODUCTIONCOST | BUSIN
+---------+---------------+----------+-------------+----------------+------
| 2 | Tamil_Movie | Action | 2016-05-17 | 112000 |
| 5 | Telugu_Movie | Action | NULL | 100000 |
| 6 | Punjabi_Movie | Comedy | NULL | 30500 |
+---------+---------------+----------+-------------+----------------+------

(g)

SELECT * FROM MOVIE


WHERE ReleaseDate IS NULL;

Output

+---------+---------------+----------+-------------+----------------+------
| MOVIEID | MOVIENAME | CATEGORY | RELEASEDATE | PRODUCTIONCOST | BUSIN
+---------+---------------+----------+-------------+----------------+------
| 5 | Telugu_Movie | Action | NULL | 100000 |
| 6 | Punjabi_Movie | Comedy | NULL | 30500 |
+---------+---------------+----------+-------------+----------------+------

Question 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".

(b) Create a table "TEAM" with following considerations:

1. It should have a column TeamID for storing an integer value between 1 to 9,


which refers to unique identification of a team.
2. Each TeamID should have its associated name (TeamName), which should be
a string of length not less than 10 characters.

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

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

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

Row 1: (1, Team Titan)


Row 2: (2, Team Rockers)
Row 3: (3, Team Magnet)
Row 4: (4, Team Hurricane)

(f) Show the contents of the table TEAM using a DML statement.
(g) Now create another table MATCH_DETAILS and insert data as shown below.
Choose appropriate data types and constraints for each attribute.

Table: MATCH_DETAILS

MatchID MatchDate FirstTeamID SecondTeamID FirstTeamScore

2018-07-
M1 1 2 90
17

2018-07-
M2 3 4 45
18

2018-07-
M3 1 3 78
19

2018-07-
M4 2 4 56
19

2018-07-
M5 1 4 32
18

2018-07-
M6 2 3 67
17

Answer

(a)

CREATE DATABASE Sports;

(b)

CREATE TABLE TEAM (


TeamID INT,
TeamName VARCHAR(20));

(c)

ALTER TABLE TEAM


ADD PRIMARY KEY(TeamID);

(d)

DESCRIBE TEAM;

Output

+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| TeamID | int | NO | PRI | NULL | |
| TeamName | char(20) | YES | | NULL | |
+----------+----------+------+-----+---------+-------+

(e)

INSERT INTO TEAM (TeamID, TeamName) VALUES


(1, 'Team Titan'),
(2, 'Team Rockers'),
(3, 'Team Magnet'),
(4, 'Team Hurricane');

(f)

SELECT * FROM TEAM;

Output
+--------+----------------+
| TeamID | TeamName |
+--------+----------------+
| 1 | Team Titan |
| 2 | Team Rockers |
| 3 | Team Magnet |
| 4 | Team Hurricane |
+--------+----------------+

(g)

CREATE TABLE MATCH_DETAILS (


MatchID VARCHAR(10),
MatchDate DATE,
FirstTeamID INT,
SecondTeamID INT,
FirstTeamScore INT,
SecondTeamScore INT,
CONSTRAINT PK_MatchID PRIMARY KEY (MatchID),
);
INSERT INTO MATCH_DETAILS (MatchID, MatchDate, FirstTeamID, SecondTeamID, F
('M1', '2018-07-17', 1, 2, 90, 86),
('M2', '2018-07-18', 3, 4, 45, 48),
('M3', '2018-07-19', 1, 3, 78, 56),
('M4', '2018-07-19', 2, 4, 56, 67),
('M5', '2018-07-18', 1, 4, 32, 87),
('M6', '2018-07-17', 2, 3, 67, 51);

Output

SELECT * FROM MATCH_DETAILS;

+---------+------------+-------------+--------------+----------------+-----
| MatchID | MatchDate | FirstTeamID | SecondTeamID | FirstTeamScore | Seco
+---------+------------+-------------+--------------+----------------+-----
| M1 | 2018-07-17 | 1 | 2 | 90 |
| M2 | 2018-07-18 | 3 | 4 | 45 |
| M3 | 2018-07-19 | 1 | 3 | 78 |
| M4 | 2018-07-19 | 2 | 4 | 56 |
| M5 | 2018-07-18 | 1 | 4 | 32 |
| M6 | 2018-07-17 | 2 | 3 | 67 |
+---------+------------+-------------+--------------+----------------+-----

Question 5

Using the sports database containing two relations (TEAM, MATCH_DETAILS)


and write the queries for the following:

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

(b) Display the MatchID of all those matches where FirstTeam has scored less
than 70 but SecondTeam has scored more than 70.

(c) Display the MatchID and date of matches played by Team 1 and won by it.

(d) Display the MatchID of matches played by Team 2 and not won by it.

(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.

Answer

(a)

SELECT MatchID
FROM MATCH_DETAILS
WHERE FirstTeamScore > 70 AND SecondTeamScore > 70;

Output

+---------+
| MatchID |
+---------+
| M1 |
+---------+

(b)

SELECT MatchID
FROM MATCH_DETAILS
WHERE FirstTeamScore < 70 AND SecondTeamScore > 70;

Output

+---------+
| MatchID |
+---------+
| M5 |
+---------+

(c)

SELECT MatchID, MatchDate


FROM MATCH_DETAILS
WHERE FirstTeamID = 1 AND FirstTeamScore > SecondTeamScore;

Output

+---------+------------+
| MatchID | MatchDate |
+---------+------------+
| M1 | 2018-07-17 |
| M3 | 2018-07-19 |
+---------+------------+

(d)
SELECT MatchID
FROM MATCH_DETAILS
WHERE SecondTeamID = 2 AND SecondTeamScore <= FirstTeamScore;

Output

+---------+
| MatchID |
+---------+
| M1 |
+---------+

(e)

ALTER TABLE TEAM RENAME TO T_DATA;


ALTER TABLE T_DATA CHANGE COLUMN TeamID T_ID int;
ALTER TABLE T_DATA CHANGE COLUMN TeamName T_NAME CHAR(20);

Question 6

A 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
COST relation. By analysing the database schema and database state, specify
SQL queries to rectify the following anomalies.

(a) M/S Wonderful Garments also keeps handkerchiefs of red colour, medium size
of Rs. 100 each.

(b) INSERT INTO COST (UCode, Size, Price) values (7, 'M', 100);

When the above query is used to insert data, the values for the handkerchief
without entering its details in the UNIFORM relation is entered. Make a provision so
that the data can be entered in the COST table only if it is already there in the
UNIFORM table.

(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.

(d) Add the constraint so that the price of an item is always greater than zero.

Answer

(b)

ALTER TABLE COST ADD CONSTRAINT fk_uniform_ucode_size FOREIGN KEY (UCode) R

(c)

ALTER TABLE UNIFORM ADD CONSTRAINT CK_UName_UCode


CHECK (UName IS NOT NULL);

(d)

ALTER TABLE COST ADD CONSTRAINT CK_Price_Positive CHECK (Price > 0);

Question 7

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 Toothpaste 54 Colgate


PCode PName UPrice Manufacturer

P03 Soap 25 Lux

P04 Toothpaste 65 Pepsodent

P05 Soap 38 Dove

P06 Shampoo 245 Dove

Write SQL queries for the following:

(a) Create the table Product with appropriate data types and constraints.

(b) Identify the primary key in Product.

(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.

(d) Add a new column Discount to the table Product.

(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.

(f) Increase the price by 12 per cent for all the products manufactured by Dove.

(g) Display the total number of products manufactured by each manufacturer.

Write the output(s) produced by executing the following queries on the basis of the
information given above in the table Product:

(h) SELECT PName, avg(UPrice) FROM Product GROUP BY Pname;

(i) SELECT DISTINCT Manufacturer FROM Product;

(j) SELECT COUNT (DISTINCT PName) FROM Product;


(k) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY
PName;

Answer

(a)

CREATE TABLE Product (


PCode VARCHAR(10) PRIMARY KEY,
PName VARCHAR(50),
UPrice int,
Manufacturer VARCHAR(50)
);

(b) The primary key in the table "Product" is PCode.

(c)

SELECT PCode, PName, UPrice


FROM Product
ORDER BY PName DESC, UPrice ASC;

Output

+-------+----------------+--------+
| PCode | PName | UPrice |
+-------+----------------+--------+
| P01 | WASHING POWDER | 120 |
| P02 | TOOTHPASTE | 54 |
| P04 | TOOTHPASTE | 65 |
| P03 | SOAP | 25 |
| P05 | SOAP | 38 |
| P06 | SHAMPOO | 245 |
+-------+----------------+--------+

(d)
ALTER TABLE Product
ADD COLUMN Discount float;

(e)

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

Output

SELECT * FROM Product;

+-------+----------------+--------+--------------+----------+
| PCode | PName | UPrice | Manufacturer | Discount |
+-------+----------------+--------+--------------+----------+
| P01 | WASHING POWDER | 120 | SURF | 12 |
| P02 | TOOTHPASTE | 54 | COLGATE | 0 |
| P03 | SOAP | 25 | LUX | 0 |
| P04 | TOOTHPASTE | 65 | PEPSODENT | 0 |
| P05 | SOAP | 38 | DOVE | 0 |
| P06 | SHAMPOO | 245 | DOVE | 24.5 |
+-------+----------------+--------+--------------+----------+

(f)

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

Output

SELECT * from Product;

+-------+----------------+--------+--------------+----------+
| PCode | PName | UPrice | Manufacturer | Discount |
+-------+----------------+--------+--------------+----------+
| P01 | WASHING POWDER | 120 | SURF | 12 |
| P02 | TOOTHPASTE | 54 | COLGATE | 0 |
| P03 | SOAP | 25 | LUX | 0 |
| P04 | TOOTHPASTE | 65 | PEPSODENT | 0 |
| P05 | SOAP | 43 | DOVE | 0 |
| P06 | SHAMPOO | 274 | DOVE | 24.5 |
+-------+----------------+--------+--------------+----------+

(g)

SELECT Manufacturer, COUNT(*) AS TotalProducts


FROM Product
GROUP BY Manufacturer;

Output

+--------------+---------------+
| Manufacturer | TotalProducts |
+--------------+---------------+
| SURF | 1 |
| COLGATE | 1 |
| LUX | 1 |
| PEPSODENT | 1 |
| DOVE | 2 |
+--------------+---------------+

(h)

SELECT PName, avg(UPrice) FROM Product GROUP


BY Pname;

Output

+----------------+-------------+
| PName | avg(UPrice) |
+----------------+-------------+
| WASHING POWDER | 120.0000 |
| TOOTHPASTE | 59.5000 |
| SOAP | 34.0000 |
| SHAMPOO | 274.0000 |
+----------------+-------------+

(i)

SELECT DISTINCT Manufacturer FROM Product;

Output

+--------------+
| Manufacturer |
+--------------+
| SURF |
| COLGATE |
| LUX |
| PEPSODENT |
| DOVE |
+--------------+

(j)

SELECT COUNT(DISTINCT PName) FROM Product;

Output

+-----------------------+
| COUNT(DISTINCT PName) |
+-----------------------+
| 4 |
+-----------------------+

(k)
SELECT PName, MAX(UPrice), MIN(UPrice) FROM
Product GROUP BY PName;

Output

+----------------+-------------+-------------+
| PName | MAX(UPrice) | MIN(UPrice) |
+----------------+-------------+-------------+
| WASHING POWDER | 120 | 120 |
| TOOTHPASTE | 65 | 54 |
| SOAP | 43 | 25 |
| SHAMPOO | 274 | 274 |
+----------------+-------------+-------------+

Question 8

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:

1. No discount is available on the LXI model.


2. VXI model gives a 10 per cent discount.
3. A 12 per cent 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 Baleno cars.

(e) List the total number of cars having no discount.

Answer

Table inventory
CarId CarName Price Model YearManufacture FuelType

D001 Dzire 582613.00 LXI 2017 Petrol

D002 Dzire 673112.00 VXI 2018 Petrol

B001 Baleno 567031.00 Sigma1.2 2019 Petrol

B002 Baleno 647858.00 Delta1.2 2018 Petrol

5 STR
E001 EECO 355205.00 2017 CNG
STD

E002 EECO 654914.00 CARE 2018 CNG

S001 SWIFT 514000.00 LXI 2017 Petrol

S002 SWIFT 614000.00 VXI 2018 Petrol

(a)

ALTER TABLE INVENTORY


ADD COLUMN Discount FLOAT;

(b)

UPDATE INVENTORY
SET Discount = 0
WHERE Model = 'LXI';

UPDATE INVENTORY
SET Discount = Price * 0.10
WHERE Model = 'VXI';

UPDATE INVENTORY
SET Discount = Price * 0.12
WHERE Model NOT IN ('LXI', 'VXI');
Output

+-------+---------+-----------+-----------+-----------------+----------+---
| CarId | CarName | Price | Model | YearManufacture | FuelType | Fi
+-------+---------+-----------+-----------+-----------------+----------+---
| D001 | Dzire | 582613.00 | LXI | 2017 | Petrol | 6
| D002 | Dzire | 673112.00 | VXI | 2018 | Petrol | 7
| B001 | Baleno | 567031.00 | Sigma1.2 | 2019 | Petrol | 6
| B002 | Baleno | 647858.00 | Delta1.2 | 2018 | Petrol | 7
| E001 | EECO | 355205.00 | 5 STR STD | 2017 | CNG | 39
| E002 | EECO | 654914.00 | CARE | 2018 | CNG | 7
| S001 | SWIFT | 514000.00 | LXI | 2017 | Petrol | 5
| S002 | SWIFT | 614000.00 | VXI | 2018 | Petrol | 6
+-------+---------+-----------+-----------+-----------------+----------+---

(c)

SELECT CarName
FROM INVENTORY
WHERE FuelType = 'Petrol'
AND Price = (SELECT MAX(Price) FROM INVENTORY WHERE FuelType = 'Petrol');

Output

+---------+
| CarName |
+---------+
| Dzire |
+---------+

(d)

SELECT AVG(Discount) AS AverageDiscount,


SUM(Discount) AS TotalDiscount
FROM INVENTORY
WHERE CarName = 'Baleno';
Output

+-----------------+----------------+
| AverageDiscount | TotalDiscount |
+-----------------+----------------+
| 72893.33984375 | 145786.6796875 |
+-----------------+----------------+

(e)

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

Output

+----------+
| COUNT(*) |
+----------+
| 2 |
+----------+

ICSE/ISC TEXTBOOK SOLUTIONS Prev STUDYLIST Next COMPANY


Database Concepts Computer Networks
Class - 6 Concise Biology Selina Solutions Java Pattern Programs Pricing

Class - 6 Veena Bhargava Geography Solutions Java Series Programs About Us

Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Contact Us

Class - 7 Concise Physics Selina Solutions Java Number Programs (ISC Classes 11 / 12) Privacy Policy

Class - 7 Concise Chemistry Selina Solutions Output Questions for Class 10 ICSE Computer Applications Terms of Service

Class - 7 Dalal Simplified Middle School Chemistry Solutions Algorithms & Flowcharts for ICSE Computers

Class - 7 Concise Biology Selina Solutions ICSE Class 8 Computers Differentiate Between the Following

Class - 7 Living Science Biology Ratna Sagar Solutions CBSE TEXTBOOK SOLUTIONS

Class - 7 Around the World Geography Solutions


Class - 7 Veena Bhargava Geography Solutions Class - 8 NCERT Science Solutions

Class - 7 Effective History & Civics Solutions Class - 9 NCERT Mathematics Solutions

Class - 8 Concise Physics Selina Solutions Class - 9 NCERT Science Solutions

Class - 8 Concise Chemistry Selina Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions

Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 9 NCERT History India & Contemporary World 1 Solutions

Class - 8 Concise Biology Selina Solutions Class - 9 Sumita Arora Computer Code 165 Solutions

Class - 8 Living Science Biology Ratna Sagar Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions

Class - 8 Around the World Geography Solutions Class - 10 NCERT Mathematics Solutions

Class - 8 Veena Bhargava Geography Solutions Class - 10 NCERT Science Solutions

Class - 8 Effective History & Civics Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions

Class - 8 Kips Logix Computers Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions

Class - 9 Concise Physics Selina Solutions Class - 10 NCERT Democratic Politics 2 (Civics) Solutions

Class - 9 Concise Chemistry Selina Solutions Class - 10 NCERT Economic Development Solutions

Class - 9 Dalal Simplified ICSE Chemistry Solutions Class - 10 Sumita Arora Computer Code 165 Solutions

Class - 9 Concise Biology Selina Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions

Class - 9 Total Geography Morning Star Solutions Class - 11 CBSE Sumita Arora Python Solutions

Class - 9 Veena Bhargava Geography Solutions Class - 11 CBSE Preeti Arora Python Solutions

Class - 9 Total History & Civics Solutions Class - 11 CBSE Informatics Practices Preeti Arora Solutions

Class - 9 Kips Logix Computers Solutions Class - 12 CBSE Sumita Arora Python Solutions

Class - 10 Concise Physics Selina Solutions Class - 12 CBSE Preeti Arora Python Solutions

Class - 10 Concise Chemistry Selina Solutions Class - 12 NCERT Computer Science Solutions

Class - 10 Dalal Simplified ICSE Chemistry Solutions Class - 12 CBSE Informatics Practices Sumita Arora Solutions

Class - 10 Concise Biology Selina Solutions Class - 12 CBSE Informatics Practices Preeti Arora Solutions

Class - 10 Total Geography Morning Star Solutions


Class - 10 Veena Bhargava Geography Solutions

Class - 10 Total History & Civics Solutions

Class - 10 Sumita Arora ICSE Computers Solutions

Class - 10 Kips Logix Computers Solutions


ICSE/ISC SOLVED QUESTION PAPERS

Class - 10 ICSE Maths Solved Competency Focused Questions

Class - 10 ICSE Biology Solved Competency Focused Questions

ICSE Class 10 Computers Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Computer Applications

ICSE Class 10 Physics Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Physics

ICSE Class 10 Chemistry Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Chemistry

ICSE Class 10 Biology Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Biology

Class - 12 ISC Computer Science Solved Practical Papers

Class - 10 CBSE Computer Applications Solved Question Papers

Class - 10 CBSE Computer Applications Solved Sample Papers

Class - 10 CBSE Science Solved Question Papers

Class - 12 CBSE Computer Science Solved Question Papers

Copyright © KnowledgeBoat 2024

You might also like