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

SQL Assignment

The document contains instructions for writing SQL queries on sample EMPLOYEE and DEPARTMENT tables. It includes 18 queries to be written on the tables covering concepts like selection, aggregation, sorting, filtering, calculations etc. Some example queries are to display employee details in ascending order of employee number, count female employees joined after a date, display names of employees with 'a' as last letter, insert new record into department table etc. Sample outputs are also given for some aggregation queries.

Uploaded by

B9B25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

SQL Assignment

The document contains instructions for writing SQL queries on sample EMPLOYEE and DEPARTMENT tables. It includes 18 queries to be written on the tables covering concepts like selection, aggregation, sorting, filtering, calculations etc. Some example queries are to display employee details in ascending order of employee number, count female employees joined after a date, display names of employees with 'a' as last letter, insert new record into department table etc. Sample outputs are also given for some aggregation queries.

Uploaded by

B9B25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

AL ALIA INTERNATIONAL INDIAN SCHOOL,RIYADH

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

8902 FAKIR ANALSYT 8566 199-12-03 3000.00 NULL 20

8934 MITA CLERK 8882 1992-01-23 1300.00 NULL 10

1. Display all the records from the table empl.


2. Display empno and employee name from the table empl
3. Display ename,sal and sal added with comm from table empl
4. Write a query to display employee name,salary and department number who are not
getting commission from the table empl
5. Write a query to display employee number,name,sal and sal*12 as annual salary whose
commission is not null from table empl
6. List the department numbers in table empl
7. List unique department numbers from table empl.
8. List details of all clerks who have not been assigned department yet
9. List the details of those employees who have four lettered names
10. List the details of employees whose annual salary in between 25000-40000
11. How many job types are offered to employees?
12. List the details of employees who earn more commission than their salaries
13. Display name,job and salary of employee who do not have manager
14. Display the name of who has A as third alphabet
15. Display name of employee whose name contains T as last alphabet
16. Display name of employee who is having L as any alphabet of the name
17. For each employee display employee name and total number of experience.
18. Write a query to display name,job,salary,hiredate who are hired in between may 20,1990
and dec 31,1991 .order the query by hire date in ascending order.

DATE OF SUBMISSION:01/10/23

Page 3 of 3

You might also like