SQL Questions
SQL Questions
Table:Department
ENO DNAME
D1 ACCOUNTS
D2 HR
D3 ADMIN
1. What is the Degree of the table EMPLOYEES? What is the Cardinality of table DEPARTMENT?
2.What is primary key ? explain
3.What is selection and projection?
Q26.Write the output of the following commands on table CUSTOMERS and PURCHASES.
Table:CUSTOMERS
CNO CNAME CITIES
C1 Sanyam Delhi
C2 Shruti Delhi
C3 Mehar Mumbai
C4 Sakshi Chennai
C5 Ritish Indore
C6 Rahul Delhi
C7 Ameer Chennai
C8 Minakshi Bangalore
C9 Anshul Mumbai
Table: Purchases
Sno Qty Pur_Date Cno
S1 15 2018-12-25 C2
S2 10 2018-11-10 C1
S3 12 2018-11-10 C4
S4 7 2019-01-12 C7
S5 11 2019-02-12 C2
S6 10 2018-10-12 C6
S7 5 2019-05-09 C8
S8 20 2019-05-09 C3
S9 8 2018-05-09 C9
S10 15 2018-11-12 C5
S11 6 2018-08-04 C7
(i) Select count(distinct cities ) from customers;
(ii) Select max(Pur_Date) from Purchases;
Select CNAME,Qty ,Pur_Date from Customers,Purchases where Customers.Cno=Purchases.Cno and Qty in(10,20);
Q27 Write SQL queries which are based on the table Customers and Purchases given in question no. 26
i) To display details of all customers whose cities are neither Delhi nor Mumbai
ii) To display the CNAME and Cities of all Customers is ascending order of their CNAME.
iii) To display the numbers of Customers along with their respective cities in each of the cities .
iv) To display details of all Purchases whose Quantity is more than 15.
Q28.Table:Teachers
TID NAME AGE DEPT DOJ SAL GENDER
T118 Navin 40 Computer 2010- 12000 M
01-10
T107 Chetna 37 History 2008- 20000 F
03-24
T105 Sandeep 46 Maths 2006- 30000 M
12-12
T110 Sangeeta 35 History 2010- 25000 F
07-01
T101 Rudransh 42 Maths 2004- 40000 M
09-05
T121 Neeraj 38 Physics 2011- 28000 M
04-01
1. To show the information about the teachers of
the history department.
30.
1. Display the Trainer Name ,City and salary in descending order of their hire date.
2. To display the TNAME and city of trainer of joined institute in the month of December 2001.
Q31.What will be the output of the following statement based on the table which are given in Q30.