Expression: (Hots
Expression: (Hots
XII
26 Display
Contai
with 'Sharma'.
23. Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name ends
with 'a'.
24. Display the AcNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name
contains 'a'.
25. Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name does
not contain 'P'.
XII
G (a) To show all information about the students of
History department.
(6) To list the names of female students who are in Hindi
department.
(c) To list names of all students with their dateofadmission in ascending order.
(d)The display Student's Name, Fees, age of male students only.
Se) To count the number ofstudentswith age>23 s e l r coud C 1* whune,5
)To insert a new row in the STUDENT table with the following data :
9, 'Zaheer, 36, 'Computer, '1997-03-12', 230, 'M
(8) Give the output of the following SQL statements :[Include the last inserted values in part (OI
) SELECT COUNT(DISTINCT department) FROM sTUDENT,
Gi) SELECT MAX(Age) FROM STUDENT WHERE Sex = "F';
(i) SELECT AVG(Fees) FROM STUDENT WHERE SEX = 'M
(iv) SELECT SUM(Fees) FROM STUDENT WHERE Dateofadm<"1998-01-01;
47. Vrite the SQL for (a) to () and write the output of the (g) on the basis of the tablTEACHER:
TABLE:TEACHER
No. Name Age Department Dateofjoin Salary Sex
Jugal 34 Computer 1997-01-10 12000 M
2 Shamila 31 History 1998-03-24 20000 F
Sangeeta. 35
History 1999-07-01 40000 F
Rakesh 2 Maths 1997-09-05 25000 M
Shyam: Historry 1998-06-27 30000 M
Shiv Om- 4
Computer 21000 M
1997-02-25
Shalakha 3 3 Maths 1997-07-31 20000
(a)To show all information about the teacher of History department.
(6) To list the name of female teachers who are in Maths department.
(c) To list names of all teachers along with their date of joining in ascending order.
(d) To display teacher's Name, Salary, age for male teacher only.
(e) To count the number of teachers with age>23.
)To insert a new row in the TEACHER table with the following data:
KARAN 34 SQUASH
BASKETBALL 2004-01-01 1500M
4 TARUN 33 SWIMMING
2004-01-12
750 M
36
ZUBIN 800
KETAKI 36 SWIMMING2004-02-24
2200
2004-02-20
SQUASH
ANKITA 2004-02-222 1100 F
ZAREEN 37 KARATE
900 M
KUSH 41 SWIMMING 2004-01-13
M
37 BASKETBALL | 2004-02-19 1700
10 SHALYA
(a) To show all information about the swimming coaches in the club. order.
their date of appointment (DATEOFAPP) in descending
6) To list namesa of all coaches with for all the coaches.
To display report, showing coach name, pay, age and bonus (15% of pay)
(d)To insert a new row in the CLUB table with thefollowing data :
11, RAJIV, 40, 'Hockey, 2000-05-27, 2006,
(e) Give the output of the following SQL statements :[Include the last inserted values in part ()]
() SELECTCOUNT(DISTINCTSPORTS) FROMCLUB;
(i) SELECT MIN(AGE) FROM CLUB WHERE SEX = "F';
XII
M () SELECT MIN(AVERAGE) FROM GRADUATE WHERE SUBJECT="PHYSICS;
M
() SELECT SUM(STIPEND) FROM GRADUATE WHERE DIVI =2;
(i) SELECTAVG(STIPEND) FROM GRADUATE WHEREAVERAGE>=65;
(iv) SELECT COUNT(DISTINCT SUBJECT) FROM GRADUATE;
50. Write SQL commands for (a) to (g) on the basis of the table SPORTS.
TABLE:SPORTS
(a) Display the names ofthe students who have grade 'C in either Gamel or Game2 or both.
(b) Display the number of students getting grade 'A' in Cricket.
()Display the names ofthe students who have same game for both Gamel and Game2.
(a) Display the games taken up by the students, whose name starts with A'.
(e) Add a new column named 'Marks.
) Assigna value 200 for Marks for all those who are getting grade 'B' or grade'A' in both Gamel and
Game2.
(g) Arrange the whole table in the alphabetical order of Name.
51. Giventhe following Lab relations: Write SQL commands for questions (a) to () and the output for ().
TABLE: Lab
Mishra 3
I50000 Business
Gupta 4
Khan 3 48000 Mixed
Chaddha 125000 Business
120000 Mixed
Yadav 2
SHOP where
Select Sum(Sale) from
(i)
from SHOP where City= 'Delhi';
(ii) Select Avg(Sale) from SHOP; command given
Count(Distinct City) write the output of the SQL
( ) Select given from (a) to () and
ofthe queries
55. Write sQL commands
FLIGHT:
based on a relation
in part (g)
Relation : FLIGHT
Distance Scats Frequency
FromCity ToCity
No FlightNo 1500 210
Yoyo Town
TI412
Blue Island
900 170
Yoyo Town
A3242 Pikswka
1000 210
Pikswaka
T1434 Perimila 1200 120
C3120 Ketty Island Blue Island
500 120
Jaswaka Perimila
T1418
Archie Land 1000 170
C3120 Pikswaka
6
323
Review of MysOL
7A3232 Harappan Valley Kety Island 900 T210
1200 120
1432 Blue Island Harappan Valley
more than 4 times in a weeK.
o display the FlightNo of those tlights which havethose
frequency
which are starting from city Blue
0)lo display FlightNo, FromCity and ToCity of all flights
Islands or are having destination as Bluc Islands.
flights in which seating capacity
is more than
To display FlightNo and Scating Capacity of all those
140
(To display FlightNo, Frequency and distance ofal those tlights, which are covering disiance more
than 900 kilometers.
(eTo display FlightNo ofall those flights which are Weekly ights and having seating capacity less
than 180.
T o insert a new flight detail in the table FLIGHT with the following data:
9,T1618, Mumsui', 'Blue Island', 1200, 210, 4
Write the output of the following:
SelectCOUNT(") from FLIGHT;
( Select MAX(Distance) from FLIGHT,
() Select MIN(Frequency) from FLIGHT;
() SelectCOUNT(Distinct FromCity) from FLIGHT,
Wnte SQL commands for the queries given from (a) to () and write the output of the SQL commands
given in part (g) based on a relation LIBRARY shown below:
Relation: LIBRARY
() Write a SQL statement to list VNo, Vname, Age for all the voters sorted on Vname.
(6) To list all those voters who are either residing in Rohini or whose age < 25.
Stock
No. e Na Price Supplier -
Intel 20
Motherboard
1000 TVSE 0
Keyboard
Mouse 500 Logitech 60
S0
4 Soundcard 600 Samsung8
Speaker 600 Samsung 1_25
Review of MysQL 327
Monitor 22
3000 Philips
7 CD-ROM 2800 Creative 32
10
Printer 7900 HP
Display data for the entire item sorted by theirname.
() Display the Name and Price from the table item in descending order of their
stock.
(Lis all Nameand Price with Price between 3000 and 7000.
(a) Write the command to set the price ficld of all products to 1200 corresponding to NAME = Keyboard,
(2 Write the SQL command to delete rows with stock between 20 to 40.
T o count the number of products with stock <5.
T o delete the column puice.
63. What is NULL value ? What is the result of an arithmtic operation containing NULL value?
64. Write SQL commands for (a) to (d) and write the outputs for (e)on the basis of table EMPLOYEE:
TABLE:EMPLOYEE
SNO NAME BASIC DEPARTMENT DATOFAPP AGE SEX
35 M
KARAN 8000 PERSONNEL 1997-03-27
2 DIVAKAR 9S00 COMPUTER 1998-01-20 34 M
(a)List the names ofthe employees who are more than 34 years old sorted by NAME.
(6) Display a report, listing NAME, BASIC, DEPARTMENT and annual salary. Annual salary equals
BASICx 12.
()To count the number of employees who are either working in PERSONNELor COMPUTER department
(d) To insert a new row in the EMPLOYEE table:
11, VIJAY, 9300, 'FINANCE, '1998-07-13, 35, M
G i v e the output of the following SQL statement based on table EMPLOYEE:
() Select SUM(BASIC) from EMPLOYEE where DEPARTMENT= "PERSONNEL;
Select AVG(BASIC) from EMPLOYEE where SEX F;
=
iin
(ii) Select MAX(BASIC) from EMPLOYEE where DATOFAPP> '1997-02-22;
(iv) Select COUNT(DISTINCT DEPARTMENT) from EMPLOYEE
for () on the basis of table
65. Write SQL commands for (a) to (e) and write the outputs
TABLE:FURNITURE
Practices XII
328 gether arck nformatics
2002-01-20 7000 20
Pink feather Baby cot
9500 20
Dolphin Baby cot 2002-02-19
25000
Decent Office Table 2002-02-01
25000 25
Comfort zone Double Bed 2002-02-12
6500 15
2002-02-24
Donald Baby cot 18000 30
Royal Finish Office Table 2002-02-20
31000 30
2002-02-22
8
Royal tiger Sofa 9500 25
9 Econo sitting Sofa 2001-12-13
Eating Paradise Dining Table 2002-02-19 11500 |25
10
FURNITURE table.
the Baby cots from the
()To show all information about than 15000 from the FURNITURE
table.
ITEMNAME which are priced at more from
(6) To list the before 2002-02-01
in which DATEOFSTOCK is
To list ITEMNAME and TYPE ofthose items,
) order ofITEMNAME.
the FURNITURE table in descending the DIScOUNT percentage
(To display ITEMNAME and
DATEOFSTOCK
ofthose items, in which
table.
is more than 25 from FURNITURE FURNITURE table.
number of items, whose TYPE is 'Sofa' from
(e) To count the
Give the output offollowing SQL statement:
from FURNITURE;
Select cOUNT(distinct TYPE)
(i). SelectMAX(DISCOUNT) from FURNITURE;
FURNITURE where TYPE "Baby cot';
=
(To display DCODE and DESCRIPTION of each dress in descending order of DOCDE.
ANSWERSTO
TOaREVOUS EARS QUESIONSTI2Marksl
1. USELBRARY,
2. ( Mname
Hirav
Rajeev
(ti) Mname
Rajeev
Sheetal
3. Number of rows are 8 and number of columns are 3.
4. Alternate key. There may be two or more attributes or combinations of attributes that uniquely identify
an instance of an entity set. In such a case, we must decide which of the candidate keys will be used as
the primary key. The remaining candidate keys would be considered alternate keys.
Candidate key. A candidate key is a combination of attributes that can be uniquely used to identify a
database record without any extraneous data. Each table may have one or more candidate keys. One of
these candidate keys is selected as the table primary key.