0% found this document useful (0 votes)
41 views2 pages

Stdxii - Sql-Questions

The document provides examples of SQL SELECT statements and queries on sample tables 'Stationery' and 'Consumer'. It includes the syntax for SELECT, examples of basic queries to display data from single or multiple tables, differences between SQL clauses and joins, and aggregate functions. Sample queries are also provided to be written and outputs found.

Uploaded by

Gunachitra PGT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

Stdxii - Sql-Questions

The document provides examples of SQL SELECT statements and queries on sample tables 'Stationery' and 'Consumer'. It includes the syntax for SELECT, examples of basic queries to display data from single or multiple tables, differences between SQL clauses and joins, and aggregate functions. Sample queries are also provided to be written and outputs found.

Uploaded by

Gunachitra PGT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SHREE NIKETAN PATASALA, TAMBARAM

GRADE 12 – COMP SCIENCE


SQL – SELECT STATEMENT

1. Write down the syntax for SELECT statement.

2. Consider the following tables Stationery and Consumer. Write SQL commands for the
statement (i) to (iv) and give output for SQL queries
(v) to (viii).
Table : STATIONERY

S_ID StationeryName Company Price


DP01 Dot Pen ABC 10
PL02 Pencil XYZ 6
ER05 Eraser XYZ 7
PL01 Pencil CAM 5
GP02 Gel Pen ABC 15

Table : CONSUMER

C_ID ConsumerName Address S_ID


01 Good Lerner Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Write & Draw Delhi PL02
16 Motivation Banglore PL01

I. To display the details of those Consumers whose Address is Delhi.


II. To display the details of Stationery whose Price is in the range of 8 to 15 (Both values
included).
III. To display the ConsumerName, Address from Table Consumer and Company and Price
from table Stationery, where price is greater than 7.
IV. To find the sum of the Price from table Stationery where company name is ‘ABC’.
V. SELECT DISTINCT Address FROM Consumer;
VI. SELECT Company, MAX(Price),Min(Price),Count(*) FROM Stationery GROUP BY
Company;
VII. SELECT C.ConsumerName, S.stationeryName, S.Price FROM Stationery S,
Consumer C WHERE C.S_Id = S.S_Id;
VIII. SELECT StationeryName, Price * 3 FROM Stationery ;
3. Write down the differences:

a) WHERE and HAVING clause


b) COUNT() and COUNT(*) function
c) EQUI JOIN and NATURAL JOIN
4. What is an aggregate function? List out the aggregate functions.

5. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to
(viii), which are based on the tables.

(i) Display the Trainer Name, City & Salary in descending order of their Hiredate.
(ii) To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000.
(iv) To display number of Trainers from each city.

(v) SELECT TID, TNAME FROM TRAINER WHERE CITY NOT IN(‘DELHI’, ‘MUMBAI’);
(vi) SELECT TNAME, CNAME, FEES FROM TRAINER, COURSE WHERE
TRAINER.TID=COURSE.TID AND FEES >10000;
(vii) SELECT TID, COUNT(*), MIN(FEES) FROM COURSE GROUP BY TID HAVING
COUNT(*)>1;
(viii) SELECT COUNT(*), SUM(FEES) FROM COURSE WHERE STARTDATE< ‘2018-09-15’;

********

You might also like