0% found this document useful (0 votes)
138 views5 pages

Prog 20 - 24

The document contains examples of SQL queries on tables containing mobile master data, mobile stock data, trainer data, course data, faculty data, watch data and student data. The queries include selecting data, filtering, sorting, aggregation, joins and modifying data. Sample outputs are provided for some queries to demonstrate their functionality.

Uploaded by

Ankitha Dharma
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)
138 views5 pages

Prog 20 - 24

The document contains examples of SQL queries on tables containing mobile master data, mobile stock data, trainer data, course data, faculty data, watch data and student data. The queries include selecting data, filtering, sorting, aggregation, joins and modifying data. Sample outputs are provided for some queries to demonstrate their functionality.

Uploaded by

Ankitha Dharma
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/ 5

20.

SQL COMMANDS -1

Mobile Master
M_ID M_COMPANY M_NAME M_PRICE M_MF_DATE
MB001 Samsung Galaxy 4500 2013-02-12
MB003 Nokia N1100 2250 2011-04-15
MB004 Micromax Unite3 4500 2016-10-17
MB005 Sony XperiaM 7500 2017-11-20
MB006 Oppo SelfieEx 8500 2010-08-21

Mobile Stock
S_ID M_ID M_Qty M_Supplier
S001 MB004 450 New Vision
S002 MB003 250 Praveen Gallery
S003 MB001 300 Classic Mobile Store
S004 MB006 150 A-one Mobiles
S005 MB003 150 The Mobile
S006 MB006 50 Mobile Centre

(i) Display the Mobile company, Mobile name & price in descending order of their
manufacturing date.
ANS:

(ii) List the details of mobile whose name starts with “S”.

ANS:

(iii) Display the Mobile supplier & quantity of all mo biles except “MB003‟.

ANS:

(iv) To display the name of mobile company having price between 3000 & 5000.

ANS:

**Find Output of following queries

(v) SELECT M_Id, SUM(M_Qty) FROM MobileStock GROUP BY M_Id;

(vi) SELECT MAX(M_Mf_Date), MIN(M_Mf_Date) FROM MobileMaster;

(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;

viii) SELECT AVG(M_Price) FROM MobileMaster;


21. SQL COMMANDS – 2

i. Display the Trainer Name, City & Salary in descending order of their Hiredate.
ANS:

ii. To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
ANS:

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:

iv. To display number of Trainers from each city.


ANS:

**Find Output of following queries


v. SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT IN(‘DELHI’, ‘MUMBAI’);

vi. SELECT DISTINCT TID FROM COURSE;

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’;
22 – SQL COMMANDS - 3

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


ANS:

ii) To display the details of courses whose fees is in the range of 15000 to 50000 (both
values included).
ANS:

iii) To increase the fees of all courses by 500 of “System Design” Course.
ANS:

(iv) To display details of those courses which are taught by ‘Sulekha’ in descending
order of courses.
ANS:

**Find output of following


v) Select COUNT(DISTINCT F_ID) from COURSES;

vi) Select MIN(Salary) from FACULTY, COURSES where COURSES.F_ID = FACULTY.F_ID;

vii) Select sum(fees) from COURSES where F_ID = 102;

vii) Select avg(fees) from COURSES;


23 – SQL COMMANDS -4

i. To display all the details of those watches whose name ends with ‘Time’
ANS:

ii. To display watch’s name and price of those watches which have price range in
between 5000-15000.
ANS:

iii. To display total quantity in store of Unisex type watches.


ANS:

iv. To display watch name and their quantity sold in first quarter.
ANS:

**Find output of following


v. select max(price), min(qty_store) from watches;

vi. select quarter, sum(qty_sold) from sale group by quarter;

vii. select watch_name,price,type from watches w, sales s where


w.watchid!=s.watchid;

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.watchi d;
24. SQL COMMANDS - 5

(i) To display the records from table student in alphabetical order as per the name of
the student.
ANS:

(ii ) To display Class, Dob and City whose marks is between 450 and 551.
ANS:

(iii) To display Name, Class and total number of st udents who have secured more than
450 marks, class wise
ANS:

(iv) To increase marks of all students by 20 whose class is “XII


ANS:

**Find output of the following queries.


(v) SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING COUNT(*)>1;

(vi ) SELECT MAX(DOB),MIN(DOB) FROM STUDENT;

(vii) SELECT NAME,GENDER FROM STUDENT WHERE CITY=’Delhi’;

-----xxx-----

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy