SQL Assignment
SQL Assignment
SUBJECT:COMPUTER SCIENCE
SIMPLE QUERIES IN SQL
CLASS:XII DATE:23/09/23
----------------------------------------------------------------------------------------------------
(1) (a)Observe the following table carefully and write the names of the most appropriate
columns, which can be considered as (i) candidate keys and (ii) primary key
(iii)alternate key
(b)Consider the following DEPT and EMPLOYEE tables. Write SQL queries for
(a) to (i) and find outputs for SQL queries (j) to (m)
Page 1 of 3
Note : DOJ refers to date of joining and DOB refers to date of Birth of employees.
a) To display Eno, Name, Gender from the table EMPLOYEE in ascending
order of Eno.
b) To display the Name of all the MALE employees from the table
EMPLOYEE.
c) To display the Eno and Name of those employees from the table
EMPLOYEE who are born between ‘1987-01-01’ and ‘1991-12-01’.
d) To count and display FEMALE employees who have joined after ‘1986-01-
01’.
e) To count unique department code from the table employee.
f) To change the location of department media to Banglore.
g) to display name of employee whose ending letter is ‘a’
h) to insert new record into the table department
i) to display the department name whose location is in delhi or kokata.
j) select count(*),dcode from employee ;
k) select distinct department from dept;
l) select max(doj), min(dob) from employee;
m) select sum(price) as “total price”,”rs” from department.
n) to display name of the employee and the number of years they worked.
Page 2 of 3
empno Ename Job Mgr Hiredate Sal Comm deptno
8369 SMITH CLERK 8902 1990-12-18 800.00 NULL 20
8499 ANYA SALESMAN 8698 1991-02-20 160.00 300.00 30
8521 SETH SALESMAN 8698 1991-02-22 1250.00 500.00 30
8566 MAHADEVAN MANAGER 8839 1991-04-02 29885.00 NULL 20
8654 MOMIN SALESMAN 8698 1991-09-28 1250.00 1400.00 10
DATE OF SUBMISSION:01/10/23
Page 3 of 3