You are on page 1of 1

3) To display Minimum and Maximum price of each

Name of Accessories.

More
4) To display Name ,Price of all Accessories and
their respective SName where they are available.
Write the output of the following SQL commands:
i) SELECT DISTINCT name FROM ACCESSORIES
WHERE price >=5000;
ii) SELECT area, COUNT(*) FROM shop GROUP BY
on Sql area;
iii) SELECT COUNT(DISTINCT area) FROM shop;
Before you solve problems read following details iv) SELECT name,price*0.05 AS “Discount” FROM
“ A Function can be defined as a set of predefined accessories WHERE Id IN(‘S002’, ‘S003’);
commands which ,when called ,performs certain CLASS TEST
operations and returns a single value” Q2. Answer the questions based on following table
Aggregate Functions: are not allowed to be used with Table: ACTIVITY
where clause because where is used on single row , ACode Activity Participants Prize ScheduleDate
where as the aggregate functions are evaluated on a Name Num Money
group of rows. 1001 Relay 16 10000 23-Jan-2004
Sum() 100x4
Avg() 1002 High 10 12000 12-Dec-2003
Max() Jump
Min() 1003 Shot 12 8000 14-Feb-2004
Count() Put
1005 Long 12 9000 01-Jan-2004
Sorting in SQL- order by ASC or DESC Jump
1008 Discuss 10 15000 19-Mar-
Group by clause can be used in select statement to Throw 2004
collect data across multiple records and group the results
by one or more columns. Table : COACH
PCode Name ACode
Having: it is used with GROUP BY clause. 1 Ahmad Hussain 1001
CLASS TEST
2 Ravinder 1008
Q1. Answer the questions based on following table
3 Janila 1001
Table :SHOP
4 Naaz 1003
ID SName Area
S001 ABC Computronics CP
Write the SQL queries:
S002 All Infotech Media GK II
1) To display the name of all activities with their Acode in
S003 Tech Shoppe CP descending order.
S004 Geel Techno Soft Nehru Place 2) To display sum of prizemoney for each of the number
S005 Hitech Tech Store Nehru Place of participants grouping (as shown in column
participantsnum 10,12,16)
Table : ACCESSORIES 3) To display the coach’s name and ACodes in ascending
No Name Price ID order of ACode from the table COACH.
A01 Mother Board 12000 S001 4) To display the content of the activity table whose
A02 Hard Disk 5000 S001 scheduledate earlier than 01/01/2004 in ascending
A03 Keyboard 500 S002 order of participantnum.
A04 Mouse 300 S001 Write the output of the following SQL commands:
A05 Mother Board 13000 S002 5) SELECT COUNT(DISTINCT ParticipantsNum) FROM
A06 Keyboard 400 S003 activity;
A07 LCD 6000 S004 6) SELECT MAX(ScheduleDate) ,MIN(ScheduleDate)
T08 LCD 5500 S005 FROM activity;
T09 Mouse 350 S005 7) SELECT SUM(PrizeMoney) FROM activity;
T10 Hard Disk 4500 S003 8) SELECT DISTINCT participantNum FROM coach;

Write the SQL queries:


1) To display Name and Price of all the Accessories *** end***
in ascending order of their price.
2) To display Id and SName of all Shop located in
Nehru Place.

You might also like