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

SQL Queries+5Tables

The document shows SQL queries and their outputs related to different tables like MobileMaster, Trainer, Faculty, Watches, and Student. It contains queries to select, update, order by, group by, having, count, max, min and aggregate functions on the table columns.

Uploaded by

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

SQL Queries+5Tables

The document shows SQL queries and their outputs related to different tables like MobileMaster, Trainer, Faculty, Watches, and Student. It contains queries to select, update, order by, group by, having, count, max, min and aggregate functions on the table columns.

Uploaded by

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

Physics Practical File

2023-24

Submitted By:____________
Class: XIIth
Submitted To:
CERTIFICATE
CLASS: Xii- YEAR:2023-24

This is to certify that Investigatory Project is


successfully completed by …..…………………………………………….
of Class: XII .Roll no. : …………………………... for the academic
year 2023-24 in the School Computer lab.

External Examiner Internal Examiner


Signature: (Subject Teacher)

Date: / / 24 Department of COMPUTER SCIENCE

PRINCIPAL
Acknowledgement

I ,…………………………… of class XIITH Roll no………………

would like to express my sincere gratitude to my computer science

teacher Mr. Prashant Kumar ,PGT COMPUTER SCIENCE, for his

vital support, guidance and encouragement – without which this

project would not have come forth.

I would also like to express my gratitude to my school St. Mary’s


Senior Secondary School for letting me use the school laboratory.
Index
1. Show Databases
2. Create a Database
3. Use database
4. Show tables
5. Create table (with different datatypes)
6. Insert Values
7. SELECT*from
8. Describing the table
9. Alter table (Add, modify, drop, rename)
10. SELECT_____ (<,>,>=,<=,=,<>)
11. SELECT_____ (AND, OR, NOT)
12. SELECT_____ (IN, NOT IN)
13. SELECT_____ (BETWEEN, NOT BETWEEN)
14. SELECT_____ (IS NULL, IS NOT NULL)
15. SELECT_____ (DISTINCT, COUNT)
16. SELECT_____ (ORDER BY [ASC/DESC])
17. SELECT____( GROUP BY HAVING)
18. SELECT____ (COLUMN ALIAS)
19. SELECT____ (LIKE, NOT LIKE)
20. UPDATE RECORDS
21. AGGREGATE FUNCTION(SUM,MIN,MAX,AVG)
1. SHOW DATABASES
mysql>
16)
21)
SQL Queries
SQL 1

(i) Display the Mobile company, Mobile name & price in descending order of
their manufacturing date.
Ans. SELECT M_Compnay, M_Name, M_Price FROM MobileMaster
ORDER BY M_Mf_Date DESC;
(ii) List the details of mobile whose name starts with “S”.
Ans. SELECT * FROM MobileMaster
WHERE M_Name LIKE “S%‟;
(iii) Display the Mobile supplier & quantity of all mobiles except “MB003‟.
Ans.SELECT M_Supplier, M_Qty FROM MobileStock
WHERE M_Id <>”MB003”;
(iv) To display the name of mobile company having price between 3000 & 5000.
Ans. SELECT M_Company FROM MobileMaster
WHERE M_Price BETWEEN 3000 AND 5000;
**Find Output of following queries
(v) SELECT M_Id, SUM(M_Qty) FROM MobileStock GROUP BY M_Id;
MB004 450

MB003 400

MB003 300

MB003 200
(vi) SELECT MAX(M_Mf_Date), MIN(M_Mf_Date) FROM MobileMaster;
2017-11-20 2010-08-21
(vii) SELECT M1.M_Id, M1.M_Name, M2.M_Qty, M2.M_Supplier
FROM MobileMaster M1, MobileStock M2 WHERE M1.M_Id=M2.M_Id
AND M2.M_Qty>=300;
MB004 Unite3 450 New_Vision

MB001 Galaxy 300 Classic Mobile Store


(viii) SELECT AVG(M_Price) FROM MobileMaster;
5450

SQL 2

i. Display the Trainer Name, City & Salary in descending order of theirHiredate.
Ans. SELECT TNAME, CITY, SALARY FROM TRAINER
ORDER BY HIREDATE;
ii. To display the TNAME and CITY of Trainer who joined the Institute in
the month of December 2001.
Ans. SELECT TNAME, CITY FROM TRAINER
WHERE HIREDATE BETWEEN ‘2001-12-01’
AND ‘2001-12-31’;
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.
Ans. SELECT TNAME,HIREDATE,CNAME,STARTDATE FROM TRAINER, COURSE
WHERE TRAINER.TID=COURSE.TID AND FEES<=10000;
iv. To display number of Trainers from each city.
Ans. SELECT CITY, COUNT(*) FROM TRAINER
GROUP BY CITY;
**Find Output of following queries
v. SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT IN(‘DELHI’,
‘MUMBAI’);
Ans.
103 DEEPTI
106 MANIPRABHA
vi. SELECT DISTINCT TID FROM COURSE;
Ans.
101
103
102
104
105
vii. SELECT TID, COUNT(*), MIN(FEES) FROM COURSE GROUP BY TID
HAVING COUNT(*)>1;
Ans. 101 2 12000
viii. SELECT COUNT(*), SUM(FEES) FROM COURSE WHERE STARTDATE<
‘2018-09-15’;
Ans. 4 65000

SQL 3

i) To display details of those Faculties whose salary is greater than 12000.


Ans: Select * from faculty
where salary > 12000;
ii) To display the details of courses whose fees is in the range of 15000 to 50000
(both values included).
Ans: Select * from Courses
where fees between 15000 and 50000;
iii ) To increase the fees of all courses by 500 of “System Design” Course.
Ans: Update courses set fees = fees + 500
where Cname = “System Design”;
(iv) To display details of those courses which are taught by ‘Sulekha’ in
descending order of courses.
Ans: Select * from faculty,courses
where faculty.f_id = course.f_id and fac.fname = 'Sulekha'
order by cname desc;
**Find output of following
v) Select COUNT(DISTINCT F_ID) from COURSES;
Ans: 4
vi) Select MIN(Salary) from FACULTY,COURSES where COURSES.F_ID =
FACULTY.F_ID;
Ans: 6000
vii) Select sum(fees) from COURSES where F_ID = 102;
Ans: 60000
vii) Select avg(fees) from COURSES;
Ans: 17500

SQL 4

i. To display all the details of those watches whose name ends with ‘Time’
Ans select * from watches
where watch_name like ‘%Time’;
ii. To display watch’s name and price of those watches which have price range in
between 5000-15000.
Ans. select watch_name, price from watches
where price between 5000 and 15000;
iii. To display total quantity in store of Unisex type watches.
Ans. select sum(qty_store) from watches where type like
’Unisex’;
iv. To display watch name and their quantity sold in first quarter.
Ans. select watch_name,qty_sold from watches w,sale s
where w.watchid=s.watchid and quarter=1;
v. select max(price), min(qty_store) from watches;
Ans. 25000 100
vi. select quarter, sum(qty_sold) from sale group by quarter;
1 15
2 30
3 45
4 15
vii. select watch_name,price,type from watches w, sales where
w.watchid!=s.watchid;
HighFashion 7000 Unisex
viii. select watch_name, qty_store, sum(qty_sold), qty_store -sum(qty_sold)
“Stock” from watches w, sale s where w.watchid=s.watchid group by s.watchid;
HighTime 100 25 75
LifeTime 150 40 110
Wave 200 30 170
Golden Time 100 10 90

SQL 5

(i) To display the records from table student in alphabetical order as per the name
of the student.
Ans. Select * from student
order by name;
(ii ) To display Class, Dob and City whose marks is between 450 and 551.
Ans. Select class, dob, city from student
where marks between 450 and 551;
(iii) To display Name, Class and total number of students who have secured more
than 450 marks, class wise
Ans. Select name,class, count(*) from student
group by class
having marks> 450;
(iv) To increase marks of all students by 20 whose class is “XII
Ans. Update student
set marks=marks+20
where class=’XII’;
**Find output of the following queries.
(v) SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING
COUNT(*)>1;
2 Mumbai
2 Delhi
2 Moscow
(vi ) SELECT MAX(DOB),MIN(DOB) FROM STUDENT;
08-12-1995 07-05-1993
(iii) SELECT NAME,GENDER FROM STUDENT WHERE CITY=’Delhi’;
Sanal F
Store M

You might also like