Madhav SQL Notes
Madhav SQL Notes
Table: MATCH_DETAILS
Match ID Match Date First Team ID Second Team First Team Second Team
ID Score Score
M1 2018-07-17 1 2 90 86
M2 2018-07-18 3 1 45 48
M3 2018-07-19 1 3 78 56
M4 2018-07-19 2 4 56 67
M5 2018-07-20 1 4 32 87
M6 2018-07-21 2 3 67 51
Table:- CLUB
COACH_ID COACH AGE SPORTS DATEOFAPP PAY SEX
NAME
1. Kukreja 35 Karate 27/03/1996 1000 M
2. Ravina 34 Karate 20/01/1998 1200 F
3. Karan 34 Squash 19/02/1998 2000 M
4. Tarun 33 BasketBall 01/01/1998 1500 M
5. Zubin 36 Swimming 12/01/1998 750 M
6. Ketaki 36 Squash 24/02/1998 800 F
7. Ankita 39 Squash 20/02/1998 2200 F
8. Zareen 37 Karate 22/02/1998 1100 F
9. Kush 41 Swimming 13/01/1998 900 M
10. Shailya 37 BasketBall 19/02/1998 1700 M
Table:- STUDENT
No. Name Stipend Stream AvgMark Grade Class
1. Karan 400.00 Medical 78.5 B 12B
2. Divakar 450.00 Commerce 89.2 A 11C
3. Divya 300.00 Commerce 68.6 C 12C
4. Arun 350.00 Humanities 73.1 B 12C
5. Sabina 500.00 Nonmedical 90.6 A 11A
6. John 400.00 Medical 75.4 B 12B
7. Robert 250.00 Humanities 64.4 C 11A
8. Rubina 450.00 Nonmedical 88.5 A 12A
9. Vikas 500.00 Nonmedical 92.0 A 12A
10. Mohan 300.00 Commerce 67.5 C 12C
1) List the names of those students who are in class 12 sorted by stipend.
2) List all students sorted by AvgMark in descending order.
3) Display a report, listing Name, Stipend, Stream and amount of stipend received in a year
assuming that the Stipend is paid every month.
4) SELECT TRUNCATE(AvgMark) FROM Student WHERE AvgMark<75;
5) SELECT ROUND(AvgMark) FROM Student WHERE Grade= ‘B’;
6) SELECT CONCAT(Name, Stream) FROM Student WHERE Class=’12A’;
7) SELECT RIGHT(Stream,2) FROM Student;
Table: SHOPPE
Code Item Company Qty City Price
102 Biscuit Hide & Seek 100 Delhi 10.00
103 Jam Kissan 110 Kolkata 25.00
101 Coffee Nestle 200 Kolkata 55.00
106 Sauce Maggi 56 Mumbai 55.00
107 Cake Britannia 72 Delhi 10.00
104 Maggi Nestle 150 Mumbai 10.00
105 Chocolate Cadbury 170 Delhi 25.00
1) To display names of items, whose name starts with ‘C’ in ascending order of price?
2) To display Code, Item name and City of the products whose quantity is less than 100.
3) To count distinct Company from the table.
4) To insert a new row in the table shoppe.
Table: HOSPITAL
No. Name Age Department Date Of Charges Sex
Adm
1 Arpit 62 Surgery 1998-01-21 300 M
2 Zarina 22 ENT 1997-12-12 250 F
3 Kareem 32 Orthopaedic 1998-02-19 200 M
4 Arun 12 Surgery 1998-01-11 300 M
5 Zubin 30 ENT 1998-01-12 250 M
6 Ketaki 16 ENT 1998-02-24 250 F
7 Ankita 29 Cardiology 1998-02-20 800 F
8 Zareen 45 Gynaecology 1998-02-22 300 F
9 Kush 19 Cardiology 1998-02-21 800 M
10 Shilpa 23 Medicine 1998-02-21 400 F
1) To display the name of the patients in Uppercase.
2) To display square root of the field charges.
3) To return the 2nd to 4th character of the field Department.
4) To find the day name of the date of Adm.
5) SELECT TRIM (‘ ABC PUBLIC SCHOOL’);
6) SELECT LENGTH (‘ABC PUBLIC SCHOOL’);
7) SELECT SUBSTR(TRIM(“ INDIA IS GREAT “)3,4);
TABLE:SHOP
No. Shop_Name Sale Area Cust_Percen Rating City
1 West Side 250000 West 68.6 C Delhi
2 Pantaloons 500000 South 81.8 A Chennai
3 Sirs & Hers 300000 North 79.8 B Amritsar
4 Sports King 380000 North 88.0 B Baroda
5 Biswas 45600 East 92.0 A Delhi
Stores
6 Big bazar 290000 South 66.7 A Kolkatta
7 Levis 230000 East 50.0 C Jameshedpur
8 Peter 428000 South 90.0 A Chennai
England
1) To display the name of all shops which are in Area south and sale more than average sales.
2) To display shop name and customer percentage of all the shops having cust_percentage is more
than 77 and less than 90.
3) To display list of all the shops with sales less than 300000 in ascending order of shop name.
4) To display the city along with sum of sale for each city.
5) To display all the columns where rating is A in the descending order of area.
6) To display all the area where more than one shop is their.
7) SELECT MIN (Sale) FROM Shop WHERE sale>300000 GROUP BY Sales;
8) SELECT COUNT(DISTINCT City)FROM Shop;
9) SELECT AVG(Sale)FROM Shop WHERE Area=”South”;
10) SELECT AVG(Cust_Percentage), SUM (Sale) FROM Shop WHERE Rating=’A’;
Table:- LOAN
Flie_No. Cust_Name PhoneNo Loan_Amt Bank Cheque_Dt
619095 Ms. Roshini 9899965430 809876 HBDC Ltd. 2017-06-15
234252 Mr. Rajesh 8654327890 745738 ICUCI Ltd. 2017-07-22
543613 Mrs. Sapna 8883546354 NULL NBI Ltd. 2017-07-24
435467 Mr. Navneet 9764747474 647484 ICUCI Ltd. 2017-08-13
263427 Ms. Puja 8746454742 546373 HBDC Ltd. 2017-08-30
Table: STUDENT
Admn Name Stream Optional Average
1001 Shrishti Science CS 90
1002 Ashi Humanities Maths 80
1003 Aditya Commerce IP 60
1004 Ritu Raj Science IP 65
1005 Sonali Commerce Maths 60
1006 Saumya Science IP 65
1007 Ashutosh Science IP 95
1008 Prashant Commerce P.ED 80
1009 Aman Commerce IP 70
1010 Rishabh Humanities P.ED 85
1) To display the details of all those students who have IP as their optional subject.
2) To display name, stream and optional of all those students whose name starts with ‘A’.
3) To give an increase of 3 in the average of all those students of humanities section who have
Maths as their optional subject.
4) To display a name list of all those students who have average more than 75.
21) Write a SQL Query to create a table “Registration” with the following structure:
Table: Registration
Q23) Mr. William wants to remove all the rows from inventory table to release the storage space, but he
does not want to remove the structure of the table. What MYSQL statement should he use?
Q24) Display the name of Employees who is working in SALES department from employee and
department.
Q25) Show the minimum, maximum and average salary of Managers from employee Table.
Q27) To show the details of employees from Employee table who joined in the year 1991.
Q28) Set the commission in employee table as 100 who are not getting any commission.
Q29) Write a query to display the name of employees whose name contains ‘A’ as third alphabet in
Ascending order of employee names.
Q30) Display the Sum of salary and commission of employees as “Total Incentive” in employee table
who are getting commission.
Q31) List the count of employees from employee table grouped by Dept Id.
Q32) Sarthaya a student of class XI, created a table “Result”. Grade is one of the column of this table. To
find the details of students whose grades have not been entered, he wrote the following MYSQL Query,
which did not give the desired result.
Help sarthaya to run the query by removing the error from the query and write the correct query.
Q33) Ajay has applied a constraint on a column such that Ajay will certainly have to insert a value in this
field, when he inserts a new row in the table. Which constraint has Ajay used?
Q34) Student table has a column named 'REMARKS' that stores Remarks. The values stored in Remarks
column in different rows are "PASS" or "NOT PASS" or "COMPTT" etc.
Write SQL Query to display details of all rows except those that have REMARK as “PASS”.
Table:RESULT
STUDENT ID NAME EXAM ID SCORE
10 Leena 1 20
10 Leena 2 25
11 Samarth 1 30
11 Samarth 2 35
12 Jai 1 14
12 Jai 2 15
14 Shoaib 1 32
14 Shoaib 2 13
Table:ACTIVITY
PID PARTICIPANT GRADE EVENT POINTS EVENTDATE HOUSE
101 Amit Dubey A Running 200 2018-12-19 Gandhi
102 Shivraj Singh Hopping Bag 300 2019-01-12 Bose
103 Raj Arora B Skipping 200 2018-12-19 Gandhi
104 Kapil Raj A Bean bag 250 2018-12-19 Bhagat
105 Deepshikha A Obstacle 350 2018-03-31 Bose
Sen
106 Saloni Raj Egg & Spoon 200 2018-12-20 Bose
Q37) The student names and marks column of a table “Student” are given below:-
Name Marks
Rohit 88
Payal 68
Nishi 98
Geetanjali NULL
Based on the above information, find the output of the following queries:
Q38) If a table “canvas” exist, then write a command that could display the structure of the table.
Q39) A table ‘Insurance’ has one of its column named salary. Give the command in MY SQL to increase
the salary of all the employees by 5%.
Q40) Rajiv wants to remove all the rows from the table “Flight” but does not want to remove the
structure of the table. Which command he should use?
Q41) A table library has 5 rows and 6 columns. However, one record is updated and two columns are
added. Then, what would be the degree and cardinality of table library.
Table:FURNITURE
NO ITEM NAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 White Lotus Double Bed 2002-02-23 3000 25
2 Pink feathers Baby Cot 2002-01-29 7000 20
3 Dolphin Baby Cot 2002-02-19 9500 20
4 Decent Office Table 2002-02-01 25000 30
5 Comfort Zone Double Bed 2002-02-12 25000 30
6 Donald Baby Cot 2002-02-24 6500 15
7 Royal Finish Office Table 2002-02-20 18000 30
8 Royal Tiger Sofa 2002-02-22 31000 30
9 Econo sitting Sofa 2001-12-13 9500 25
10 Eating Paradise Dinning Table 2002-12-19 11500 25
1) To list the item name and discount which are priced more than 15000 from the furniture table
and whose type ends with d.
2) To list item name and type of those items, in which dateofstock is before 2002-02-01 from the
furniture table in descending order of itemname.
3) To display itemname and dateofstock of those items, in which the discount percentage is more
than 25 from the furniture table.
4) To count the number of items, whose TYPE is “Sofa” from the furniture table.
5) Write a command to add a new column warranty whose data type would be integer of size 10.
6) To display type and price of those items which have price in range of 3000 and 10000.
7) SELECT COUNT(DISTINCT Type) FROM Furniture;
8) SELECT MAX(Discount)FROM Furniture;
9) SELECT AVG(Discount) FROM Furniture WHERE Type=”Baby Cot”;
10) SELECT SUM(Price) FROM Furniture WHERE Dateofstock<2002-02-12;
Doc_Name
Ragav
Wilson
Vicky
Deepak
Paras
Q45) A table BANK has 13 columns and 9 rows then added 4 rows and dropped 4 columns. Write the
degree and cardinality of BANK table.
a) SELECT Round(6.5675,2);
b) SELECT TRUNCATE(5.3456,1);
c) SELECT DAYOFMONTH(‘2009-08-25’);
d) SELECT MID(‘Class 12’, 2,3);
e) SELECT DAYOFYEAR(‘2019-12-15’);
f) SELECT SUBSTR(Informatics,2,4);
Q47) A numeric data field AMOUNT stores the value as 30309.98. Write a command in SQL to Round off
amount:-
With reference to the above given tables, write commands in SQL for (i) and (ii) and output for (iii)
below:
i) To display the Item Code, Item Name and Received Date of all the items.
ii) To display SAP ID, Item Name, Item Storage Location of all the items whose Received date is after
2nd May 2016.
iii) SELECT SAP ID, Item Name, STORE ID FROM SAP, Store WHERE SAP. Item Code=Store. Item Code
AND Store Location= “Hauz Khas”;
Table: FLIGHTS
FL_No START ENDING NO_FLIGHTS NO_STOPS
IC301 MUMBAI DELHI 8 0
IC799 BENGALURU DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 1
AM812 KANPUR BENGALURU 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI THIRUVANANTHA 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
Table:FARES
FL_NO AIRLINES FARE TAXRATE
IC701 Indian Airlines 6500 10
MU499 Sahara 9400 5
AM501 Jet Airways 13400 8
IC899 Indian Airlines 8300 4
IC302 Indian Airlines 4300 10
UC799 Indian Airlines 10500 10
MC101 Deccan Airlines 3500 4
ii) Display FL_NO and NO_FLIGHTS from “Kanpur” to “Bangalore” and airlines is Sahara.
iii) Arrange the contents of the table FLIGHT in the ascending order of FL_NO.
iv) Display the FL_NO and fare to be paid for the flights from Delhi to Mumbai using the tables flight
and fares, where the fare to be paid=FARE+FARE*TAX/100.
v) Display the starting, ending and Airlines of all the flights having fare more than 8000.
Table:EMPLOYEE
ENO ENAME SALARY ZONE AGE GRADE DEPT
1 Mona 70000 East 40 A 10
2 Muktar 71000 West 45 B 20
3 Nalini 60000 East 26 A 10
4 Sanaj 65000 South 36 A 20
5 Surya 58000 North 30 B 30
Table: DEPARTMENT
DEPT DNAME HOD
10 Computers 1
20 Economic 2
30 English 3
i) To display ENO, ENAME, SALARY and Corresponding Dname of all the employees whose age is
between 25 and 35.
ii) To display Dname and corresponding Ename from the table Department and Employee.
Hint: HOD of the Department table should be matched with ENO of the Employee table for getting the
desired result.
iii) To display Ename, Salary, Zone and Income Tax (Note:- Income Tax to be calculated 30% of salary) of
all the employees with appropriate column headings.
Table: EMPLOYEE
EMPLOYEE ID NAME SALES JOB ID
E1 Sumit Sinha 110000 102
E2 Vijay Singh Tomar 1300000 101
E3 Ajay Rajpal 1400000 103
E4 Mohit Ramnani 1250000 102
E5 Shailja Singh 1450000 103
Table: JOB
JOB ID JOB TITLE SALARY
101 President 200000
102 Vice President 125000
103 Administration Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000
i) To display Employee Id’s, Names of Employee, Job Id’s with corresponding job titles.
ii) To display names of employees, Sales and corresponding job titles who have achieved sales
more than 1300000.
iii) To display names and corresponding job titles of those employee who have ‘SINGH’ in their
names.
iv) Identify foreign key in the table EMPLOYEE.
v) Write SQL Command to change the JOB ID to 104 of the EMPLOYEE with ID as E4 in the table
Employee.
Table: DOCTORS
DOC ID DOCNAME DEPARTMENT OPP_DAYS
101 M.Pandey ENT TTF
102 G.P. Gupta PAED MWF
201 K. Sharma Ortho MWF
Table:PATIENTS
PAT NO PAT NAME DEPARTMENT DOC ID
1 Neeraj ENT 101
2 Mohit Ortho 201
3 Ragini ENT 101
4 Mohit Paed 102
5 Nandini Ortho 201
i) Display the PatNo, Pat Name and corresponding Doc Name for each Patient.
ii) Display the list of all patients whose OPD_Days are MWF.
iii) SELECT OPD_Days, Count(*)
FROM Doctors, Patients
WHERE Patients.Department=Doctors.Department
GROUP BY OPD_Days;
Table: HANDSETS
SETCODE SET NAME TOCUH SCREEN PHONE COST
N1 Nokia 2G N 5000
N2 Nokia 3G Y 8000
B1 BlackBerry N 14000
Table:CUSTOMER
CUST NO SET NO CUST ADDRESS
1 N2 Delhi
2 B1 Mumbai
3 N2 Mumbai
4 N1 Kolkata
5 B1 Delhi
i) Display the Cust No, Cust Address and corresponding Set name for each customer.
ii) Display the customer Details for each customer who uses a Nokia handset.
iii) SELECT Set No, Set Name
FROM Handset, Customer
WHERE Set No=Set Code AND Cust Address=’Delhi’;
Table: GARMENT
GCODE DESCRIPTION PRICE FCODE READY DATE
10023 Pencil Skirt 1150 F03 19-Dec-10
1
10001 Formal Shirt 1250 F01 12-Jan-10
10012 Informal Shirt 1550 F02 06-Jun-10
10024 Baby Top 750 F03 07-APR-09
10090 Tulip Skirt 850 F02 31-Mar-09
10019 Evening Gown 850 F03 06-Jun-10
10007 Informal Pant 1500 F02 20-Oct-10
10017 Formal Pant 1350 F01 09-Mar-10
10020 Frock 850 F04 09-Sep-09
10089 Slacks 750 F03 31-Oct-10
Table:FABRIC
FCODE TYPE
F04 Polyster
F02 Cotton
F03 Silk
F01 Terelene
i) To display the details of all the garments, which have Ready date in between 08-Dec-09 and
16-Jun-10.
ii) To display FABRIC wise highest and lowest price of garments from Garment Table.(Display
Fcode of each garment along with highest and lowest price).
iii) SELECT Description, Type FROM Garment, Fabric
WHERE Garment. Fcode= Fabric.Fcode AND Garment.Price>=1260;
iv) SELECT Max(Fcode) FROM Fabric;
Table:ITEM
I_ID Item Name Manufacturer Price
PC01 Personal Computer ABC 35000
LC05 Laptop ABC 55000
PC03 Personal Computer XYZ 32000
PC06 Personal Computer COMP 37000
LC03 Laptop PQR 57000
Table:CUSTOMER
C_ID Customer Name City I_ID
01 Mrs. Rekha Delhi LC03
06 Mansh Mumbai PC03
12 Rajeev Delhi PC06
15 Yajnesh Delhi LC03
16 Vijay Bangalore PC01
Table:PRODUCT
P_ID PRODUCT NAME MANUFACTURER PRICE
TP01 Talcum Powder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95
Table: CLIENT
C_ID CLIENT NAME CITY P_ID
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Woman Delhi FW12
16 Dreams Bangalore TP01
Table: SENDER
SENDER ID SENDER NAME SENDER ADDRESS SENDER CITY
ND01 RJain 2, ABC Appts New Delhi
MU02 N Sinha 12, Newton Mumbai
MU15 SJha 27/A, Park Street Mumbai
ND50 TPrasad 122-K, SDA New Delhi
Table: RECIPIENT
REC ID SENDER ID REC NAME REC ADDRESS RECCITY
Ko05 ND01 R Bajpayee 5, Central Avenue Kolkatta
ND08 MU02 S Mahajan 116, A Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 PK Swamy B5, CS Terminus Mumbai
ND 48 ND 50 S Tripathi 13, B1D, Mayur New Delhi
Vihar
Table:CONSIGNOR
CNOR ID CNOR NAME CNOR ADDRESS CITY
ND01 R Singhal 24, ABC Enclave New Delhi
ND02 Amit Kumar 123, Palm Avenue New Delhi
MU15 R Kohli 5/A, South Street Mumbai
MU50 S Kaur 27-K, Westend Mumbai
Table:CONSIGNEE
CNEE ID CNOR ID CNEE NAME CNEE ADDRESS CITY
MU05 ND01 Rahul Kishore 5, Park Avenue Mumbai
ND08 ND02 P Dhingra 16/J, Moore New Delhi
Enclave
KO19 MU15 AP Roy 2A, Central Kolkata
Avenue
MU32 ND02 S Mittal P245, AB Colony Mumbai
ND48 MU50 BP Jain 13, Block D, A New Delhi
Vihar
Table: STORE
SNO SNAME AREA
S01 ABC Computronics GKII
S02 All Infotech Media CP
S03 Tech Shoppe Nehru Place
S04 Geeks Technosoft Nehru Place
S05 Hitech Tech Store CP
Table:ITEM
INO INAME PRICE SNO.
T01 Motherboard 12000 S01
T02 Harddisk 5000 S01
T03 Keyboard 500 S02
T04 Mouse 300 S01
T05 Motherboard 13000 S02
T06 Keyboard 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03
1) To display Iname and price of all the Items in ascending order of their price.
2) To display SNO and SNAME of all stores located in CP.
3) To display minimum and maximum price of each Iname from the table Item.
4) To display Iname, Price of all items and their respective SName Where they are available.
5) SELECT DISTINCT Iname FROM Item WHERE Price>=5000;
6) SELECT AREA, Count(*) FROM Store GROUP BY Area;
7) SELECT COUNT(DISTINCT AREA) FROM Store;
8) SELECT IName, Price*0.05 Discount FROM Item WHERE SNO. IN(‘S02’, S03’);
Table:STOCK
Item No Item Dcode Qty Unit Price Stock Date
5005 Ball Pen 0.5 102 100 16 31-Mar-10
5003 Ball Pen 0.25 102 150 20 01-Jan-10
5002 Gell Pen 101 125 14 14-Feb-10
Premium
5006 Gel Pen Classic 101 200 22 01-Jan-09
5001 Eraser Small 102 210 5 19-Mar-09
5004 Eraser Big 102 60 10 12-Dec-09
5009 Sharpener 103 160 8 23-Jan-09
Classic
Table:DEALERS
DCODE DNAME
101 Reliable Stationers
103 Classic Plastics
102 Clear Deals
1) To display details of all items in the stock table in ascending order of stock Date.
2) To display Item No. and Item Name of those from stock table whose unit price is more than
Rupees 10.
3) To display the details of those items whose Dealer Code is 102 or Quantity in stock is more than
100 from the table stock.
4) To display Maximum unit price of Items for each dealer individually as per dcode from the table
stock.
5) SELECT Count(DISTINCT Dcode) FROM Stock;
6) SELECT Qty*Unit Price FROM STOCK;
7) SELECT Item, Dname FROM Stocks, Dealers
WHERE Stock.Dcode= Dealer.Dcode AND Item No.=5004;
8) SELECT MIN(Stock Date) FROM Stock;
Q62)Write a SQL Function to remove leading and trailing spaces from a character expression P, where
Q63) Write the commands to display the name of passenger and address of all the passengers after
removing the leading and trailing blanks from the table PASSMAST.
Q64) Write the command to convert the message “ABC INTERNATIONAL PUBLIC SCHOOL” to Lower
case.
Doc_Name
Avinash
Hariharan
Vinayak
Deepak
Sanjeev
Based on the information, find the output of the following queries:-
1) SELECT Doc_name FROM Hospital WHERE Doc_Name LIKE’%V’;
2) SELECT Doc_name FROM Hospital WHERE Doc_name LIKE ‘%ee%’;
Q67) Anurag, a student of class XI created a table “PLAYER SCORE”. Current Score is one of the column
of this table. To find the details of players whose current score is more than 100, he wrote the following
MYSQL query, which did not give the desired result.
SELECT * FROM PLAYER_SCORE
WHERE Current_Score>”100”;
Help Anurag to run the query by removing the errors from the query and write the correct query.
Table:EMP
ID NAME AGE ADDRESS SALARY PHONE
1 Siddharth 25 A-4, Ashok 62000 98110766656
Vihar, Delhi
2 Chavi 23 B-21, Model 71000 99113423989
Town, Mumbai
3 Karan 26 KC-24, North 65000 98105393578
Avenue,
Bhopal
4 Raunaq 22 A-152, Gomti 89000 99101393576
Nagar,
Lucknow
5 Kunal 27 B-5/45, Uday 80000 97653455654
Park, Delhi
1) To display list of all employees below 25 years old.
2) To list names and respective salaries in descending order of salary.
3) To count the number of employees with names starting with ‘K’.
4) To list names and addresses of those persons who have ‘Delhi’ in their address.
5) SELECT Name, Salary FROM EMP WHERE Salary BETWEEN 50000 and 70000
6) SELECT Name, Phone from EMP where Phone LIKE ‘99%’;
Table:PHARMADB
RXID DRUG ID DRUG NAME PRICE PHARMACY PHARMACY
NAME LOCATION
R1000 5476 Amlodipine 100.00 RX Pharmacy Pitampura,
Delhi
R1001 2345 Paracetamol 15.00 Raj Medicos Bahadurgarh,
Haryana
R1002 1236 Nebistor 60.00 My Chemist Rajouri
Garden, Delhi
R1003 6512 Vitaplus 150.00 My Chemist Gurgaon,
Haryana
R1004 5631 Levocitrezine 110.00 RX Pharmacy South
Extension,
Delhi
1) To increase the price of “Amlodipine” by 50.
2) To display all those medicines whose price is in the range 100 to 150.
3) To display the maximum price offered by Pharmacy located in “Gurgaon”.
4) To display the Drug ID, Drug Name and pharmacy Name of all the records in descending order of
their price.
5) SELECT RX ID, Drug Name, Price FROM Pharma DB WHERE Pharmacy Name IN(“RX Pharmacy”,
Raj Medicos”);
6) SELECT Pharmacy Name, Count(*) FROM Pharma DB ORDER BY Price DESC;
Table:LIBRARY
S.NO. TITLE AUTHOR TYPE PUB QTY PRICE
1 Data Lipschutz DS Mcgraw 4 217
Structure
2 Computer French FND Galgotia 2 75
Studies
3 Advanced Schildt PROG Mcgraw 4 350
Pascal
4 Dbase Palmer DBMS Pustak M 5 130
Dummies
5 Mastering G Verewish PROG BPB 3 295
C++
6 Guide Freed NET 2 Press 3 200
Network
7 Mastering Seigal DBMS BPB 2 135
Foxpro
8 DOS Guide Norton OS PHI 3 175
9 Basic of Morton PROG BPB 3 40
beginner
10 Mastering Cowart OS BPB 1 225
Windows
1) Select all the PROG type published by BPB from library.
2) Display a list of all books with price more than 130 and sorted by qty.
3) Display all books sorted by price in ascending order.
4) Display all report, listing Books title, Current value and misplaced charges for each book in above
table.
Calculate the misplacement charges for all books price*1.25.
5) Count the number of books in above table.
6) Insert a new book in library table with following values:-
“Exploring C”, “Yashwant”, “PROG”, “BPB”, 3,2308
7) SELECT MIN(Price) FROM Library WHERE Price<150;
8) SELECT AVG(Price) FROM Library WHERE Qty<3;
9) SELECT Count(DISTINCT Pub) FROM Library;
Table:SBOP
ACCOUNT NO. NAME BALANCE DATE OF OPEN TRANSACTION
SB-1 Mr. Anil 15000.00 2011-02-24 7
SB-2 Mr. Amit 23567.89 8
SB-3 Mrs. Sakshi 45000.00 2012-02-04 5
SB-4 Mr. Gopal 23812.35 2013-09-22
SB-5 Mr. Dennis 63459.80 2009-11-10 15
1) Display Account No., Name and Date of open of account holders having transactions more than
8.
2) To display all information of account holders whose transaction value is not mentioned.
3) To add another column Address with data type and size as VARCHAR(25).
4) To display the month day with Date of Open for all the account holders.
5) SELECT Count(*) FROM SBOP;
6) SELECT Name, Balance
FROM SBOP WHERE Name LIKE ‘%i’;
7) SELECT ROUND(Balance, -3) FROM SBOP
WHERE Account No=”SB-5”;
Table:EXAM
ADNO SNAME PERCENTAGE CLSECTION STREAM
R001 Sushant 90.2 12A Science
R002 Vaidyanath 80.5 12B Humanities
R003 Miara 68.9 12B Science
R004 Niara 96.0 12A Commerce
R005 Shinjini 88.9 12D Commerce
1) To display all information of the students of humanities in descending order of percentage.
2) To display Ad no, Name, Percentage and Stream of those students whose name is less than 6
characters long.
3) To add another column Bus_Fees with data type and size as Decimal(8,2).
4) To increase the percentage by 2% of all the humanities students.
5) SELECT COUNT(*) FROM Exam;
6) SELECT SName, Percentage FROM Exam WHERE Name LIKE’N%’;
7) SELECT ROUND(Percentage,0) FROM Exam WHERE Ad no=”R005”;
Table:GYM
ICODE INAME PRICE BRANDNAME
G101 Powerfit Exerciser 20000 Power Gymea
G102 Aquafit Hand Grip 1800 Reliable
G103 Cycle Bike 14000 Ecobike
G104 Protoner Extreme Gym 30000 Coscore
G105 Massage Belt 5000 Msaaage Expert
G106 Cross Trainer 13000 GTC Fitness
1) To display the names of all the items whose name starts with ‘A’.
2) To display I Codes and I Names of all items whose Brand name is Reliable or Coscore.
3) To change the Brand name to ”Fit Trend India” of the item whose Icode is “G101”.
4) Add a new row fornew item in GYM with the details:-
5) “G107”, “Vibro Exerciser”, 21000, “GTC Fitness”
6) SELECT COUNT(DISTINCT (Brand Name)) FROM GYM;
7) SELECT MAX(Price) FROM GYM;
8) SELECT I Name FROM Gym WHERE I NameLIKE “%t”;
Table: FITNESS
PCODE PNAME PRICE MANUFACTURER
P1 Treadmill 21000 Coscore
P2 Bike 20000 Aone
P3 Cross Trainer 14000 Reliable
P4 Multi Gym 34000 Coscore
P5 Massage Chair 5500 Regrosene
P6 Belly Vibrator Belt 6500 Ambawya
1) To display the names of all the products with price more than 20000.
2) To display the names of all products by the manufacturer “Aone”.
3) To change the price data of all the products by applying 25% discount reduction.
4) To add a new row for product with the details:-
“P7”, “Vibro Exerciser”, 28000, “Aone”.
5) SELECT * FROM Fitness
WHERE Manufacturer Name LIKE “%e”;
6) SELECT COUNT(DISTINCT(Manufacturer)) FROM Fitness;
7) SELECT MAX(Price) FROM Fitness;
Table:RESULT
NO NAME STIPEND SUBJECT AVERAGE DIVISION
1 Sharon 400 English 38 Third
2 Amal 680 Mathematics 72 First
3 Vedant 500 Accounts 67 First
4 Shanker 200 Informatics 55 Second
5 Anandha 400 History 85 First
6 Upasna 550 Geography 45 Third
1) To list the names of those students, who have obtained Division as First in the ascending order
of Name.
2) To display a report listing Name, Subject and Annual Stipend received assuming that the stipend
column has monthly stipend.
3) To count the number of students, who have either Accounts or Informatics as Subject.
4) To insert a new row in the table Result:-
7, “Mohan”, 500, English, 73, “Second”
5) SELECT AVG(Stipend) FROM Result
WHERE DIVISION=”THIRD”;
6) SELECT COUNT(DISTINCT Subject) FROM Result;
7) SELECT MIN (AVERAGE) FROM Result
WHERE Subject=”English”;
Table:FLIGHT
NO FLIGHT NO FROM CITY TO CITY DISTANCE SEATS FREQUENCY
1 T1412 Blue Island Yoyo Town 1500 210 3
2 A3242 Pikswka Yoyo Town 900 170 7
3 T1434 Perimila Pikswka 1000 210 7
4 C3120 Ketty island Blue Island 1200 120 4
5 T1418 Jaswaka Perimila 500 120 1
6 C3120 Pikswaka Archie Land 1000 170 4
7 A3232 Harappan Ketty Island 900 210 1
Valley
8 T1432 Blue Island Harappan 1200 120 2
Valley
1) To display the Flight No. of those flights which have frequency more than 4 times in a week.
2) To display the Flight No, From city and To city of all those flights which are starting from city
Blue Islands or are having destination as blue Islands.
3) To display Flight No and seating capacity of all those flights in which seating capacity is more
than 140.
4) To display Flight No, Frequency and distance of all those flights which are covering distance
more than 900 kilometers.
5) To display Flight No of all those flights which are weekly flights and having seating capacity less
than 180.
6) To insert a new flight detail in the table FLIGHT with the following data:-
7) 9, ‘T1618’, “Mumsui”, “Blue Island”, 1200, 210, 4.
8) SELECT COUNT(*) FROM Flight;
9) SELECT MAX (Distance) FROM Flight;
10) SELECT MIN(Frequency) FROM Flight;
11) SELECT COUNT(DISTINCT FROM City) FROM Flight;