XII CS DBMS & SQL Connectivity & Networking-Worksheet
XII CS DBMS & SQL Connectivity & Networking-Worksheet
XII CS DBMS & SQL Connectivity & Networking-Worksheet
Table: JOB
Jobid Jobtitle Salary
101 President 200000
102 Vice President 125000
103 Administrative assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
a) To display the employee id’s, employee names, job id’s and their corresponding job titles.
b) To display the names of employees, sales and the corresponding job titles who have achieved sales more
than 1300000.
c) To display names and corresponding job titles of those employees who have ‘SINGH’ in their names.
d) To display the frequency of employees jobwise.
e) To display the highest sales achieved by employees for each job.
f) To display the sum of sales achieved by the employees jobwise with the total sales more than 200000.
g) To display the average sales for all the jobs with more than 1 people for a job.
h) To display the id and names of all the employees with their salary.
i) To display the job titles in the descending order of their salary.
j) To display the employee names with their salary.
k) Select E.name, E.sales, J.salary from EMPLOYEE as E INNER JOIN JOB as J ON E.jobid=J.jobid;
l) Select J.jobid, J.jobtitle, J.salary, E.sales from EMPLOYEE RIGHT JOIN JOB ON E.jobid=J.jobid;
m) Select min(sales) from EMPLOYEE where name not like ‘_ _A%’;
25. Consider the table below.
Table: STUDENT
Rollno Name Class DOB Gender City Marks
1 Nanda X 2004-06-04 M Agra 551
2 Saurabh XII 2006-12-11 M Mumbai 462
3 Sanal XI 2005-10-15 F Delhi 400
4 Trisla XII 2006-10-05 F Mumbai 450
5 Schewart XII 2006-04-02 M Delhi 369
6 Marisla XI 2004-08-18 F Dubai 250
7 Neha X 2004-06-06 F Moscow 377
8 Nishant X 2004-02-03 M Moscow 489
Write the output for the following SQL Queries.
i) Select count(*), city from STUDENT Group By city having count(*)>1;
ii) Select max(marks), min(marks) from STUDENT;
iii) Select sum(marks) from STUDENT where DOB>=’2005-01-01’;
Write the SQL queries for the following.
iv) To display the name, class and total number of students who have secured more than 400 marks, classwise.
v) To display the number of distinct values of the city column.
vi) To display the average of marks for female students classwise..
vii) To display the number of male students citywise.
viii) To display the records from the table STUDENT in alphabetical order as per the name of the student.
ix) To display the highest marks of class XII.
26. Consider the tables given below. Write the output for the following SQL queries.
i) SELECT COUNT(*) , CITY FROM COMPANY GROUP BY CITY;
ii) SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
iii) SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
iv) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
v) SELECT DISTINCT PRODUCTNAME FROM COMPANY;
Write the SQL queries for the following.
vi) To display the customer id, name and the corresponding company where the price ranges between
50000 and 70000.
vii) To display the Cartesian product of the tables COMPANY and CUSTOMER.
viii) To display the number of companies citywise.
ix) To display the highest price of each company with more than 1 for a company.
x) To display the total quantity for the customers whose name contains starts with ‘S’ and ends with
‘L’.
27. Consider the tables below. Write the queries for 1 and 2. Write the output for 3 to 6.
i) TO DISPLAY TOTAL QUANTITY IN STORE OF UNISEX TYPE WATCHES.
ii) TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN FIRST QUARTER;
iii) SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
iv) SELECT QUARTER, SUM(QTY SOLD) FROM SALE GROUP BY QUARTER;
v) SELECT WATCH_NAME, PRICE, TYPE FROM WATCHES W, SALE S WHERE W.
WAT£H1D!=S.WATCHID;
vi) SELECT WATCH_NAME, QTYSTORE, SUM (QTY_SOLD), QTY_STORESUM (QTYSOLD)
“STOCK” FROM WATCHES W, SALE S WHERE W. WATCHID = S.WATCHID GROUP BY
S.WATCHID;