DATE: 26.09.2020: Sample Table - Worker
DATE: 26.09.2020: Sample Table - Worker
2020
EX No: 03
CREATE:
INSERT:
CREATE:
INSERT:
CREATE:
INSERT:
1. Write an SQL query to fetch “FIRST_NAME” from Worker table using the alias name as <WORKER_NAME>.
2. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case.
3. Write an SQL query to fetch unique values of DEPARTMENT from Worker table.
QUERY: Select distinct DEPARTMENT from Worker;
OUTPUT OF THE QUERY:
4. Write an SQL query to print the first three characters of FIRST_NAME from Worker table.
5. Write an SQL query to find the position of the alphabet (‘a’) in the first name column ‘Amitabh’ from Worker table.
6. Write an SQL query to print the FIRST_NAME from Worker table after removing white spaces from the right side.
QUERY: Select RTRIM(FIRST_NAME)from Worker;
OUTPUT OF THE QUERY:
7. Write an SQL query that fetches the unique values of DEPARTMENT from Worker table and prints its length.
8. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME Ascending.
9. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME Ascending and
DEPARTMENT Descending.
QUERY: Select*from Worker order by FIRST_NAME asc, DEPARTMENT desc;
OUTPUT OF THE QUERY:
10. Write an SQL query to print details of Workers with DEPARTMENT name as “Admin”.
11. Write an SQL query to print details of the Workers whose FIRST_NAME contains ‘a’.
12. Write an SQL query to print details of the Workers whose SALARY lies between 100000 and 500000.
QUERY: Select*from Worker where SALARY between 100000 and 500000;
OUTPUT OF THE QUERY:
13. Write an SQL query to print details of the Workers who have joined in Feb’2014.
14. Write an SQL query to fetch the count of employees working in the department ‘Admin’.
15. Write an SQL query to fetch worker names with salaries >= 50000 and <= 100000.
16. Write an SQL query to fetch the no. of workers for each department in the descending order.
17. Write an SQL query to print details of the Workers who are also Managers.
19. Select the record present in Worker and not in title table.
21. Write an SQL query to fetch the list of employees with the same salary.
QUERY: Select distinct W.WORKER_ID, W.Salary from Worker W, Worker W1 where W.salary and
W.WORKER_ID !=W1.WORKER_ID;
OUTPUT OF THE QUERY: