Assignment SQL
Q1. Given the following relation, answer the questions
Table: EMP
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 Sunita Sharma Clerk 7902 1990-12-17 12800 NULL 20
7499 Ashok Singhal Salesman 7698 1991-02-20 13600 1300 30
7521 Sumit Avasti Salesman 7698 1991-02-22 15250 1500 30
7566 Jyoti Lamba Manager 7839 1991-04-02 14975 NULL 20
7654 Martin S. Salesman 7698 1991-09-28 16250 2400 30
7698 Binod Goel Manager 7839 1991-05-01 15850 NULL 30
7782 Chetan Gupta Manager 7839 1991-06-09 12450 NULL 10
7788 Sudhir Rawat Analyst 7566 1997-04-19 15000 NULL 20
7839 Kavita Sharma President NULL 1991-11-17 1500 NULL 10
7844 Tushar Tiwari Salesman 7698 1991-09-08 14500 0 30
7876 Anand Rathi Clerk 7788 1997-05-23 16100 NULL 20
7900 Jagdeep Rana Clerk 7698 1991-12-03 14950 NULL 30
7902 Sumit Vats Analyst 7566 1991-12-03 13500 3600 20
7934 Manoj Kaushik Clerk 7782 1991-01-23 15300 NULL 10
1. Display all the record of emp table.
2. Display employee number, name and salary of all employee.
3. Display employee no., name and 10% of salary for each
emplaoyee for earthquake fund who joined before 2001.
4. To display the detail of employees whose salary is not more
than 15000.
5. Display name and salary of all employees whose salary is greater
then equal to 20000.
6. Display employee no and name of employees whose deptno is 30
and salary more than 15000
7. Display all the information except ‘Jagdish Rana’.
8. Display the employee name either ‘Sumit Vats’ or ‘Chetan Gupta’.
9. Display the detail of employees whose commission is
NULL.
10.Display distinct department from the table.
11.Display employee no., name and salary of all employees whose
salary between 15000 and 20000.
12.To display employee no., name and job of employees
whose employee no. 7876, 7839, 7788, 7566.
13.Display employee no. and name whose name start alphabet ‘S’.
14.Display employee no, name and salary of employees whose name
‘s second character is ‘a’.
15.Display employee no, name and salary of employees whose name
‘s second last character is ‘n’.
16.Display employee no, name and salary of employees whose name
‘s last character is ‘a’.
17.Display employee no, name and salary of employees whose name
‘s contain ‘i’.
18.Display employee no., name except 7788, 7839, 7900.
19.Display all the employee no and name whose commission is
not NULL.
20.Display employee no and name whose salary is not in between
15000 and 20000.
21.Display employee no., name and annual salary of all employee.
Annual salary will be calculated as salary into 12. Use column
alias. 22.Write a query to update all the records with an increment of
RS. 500 whose salary is less than 15000.
COMMANDS
#1
#2
#3
#4
#5