KEMBAR78
SQL Task1 | PDF | Sql | Software Design
0% found this document useful (0 votes)
39 views6 pages

SQL Task1

Uploaded by

sahil fuck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views6 pages

SQL Task1

Uploaded by

sahil fuck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Let’s prepare sample data for SQL practice.

Sample Table – Worker


WORKER_ID FIRST_NAM LAST_NAME SALARY JOINING_DATE DEPARTMENT
E

001 Monika Arora 100000 2014-02-20 09:00:00 HR


002 Niharika Verma 80000 2014-06-11 09:00:00 Admin
003 Vishal Singhal 300000 2014-02-20 09:00:00 HR
004 Amitabh Singh 500000 2014-02-20 09:00:00 Admin
005 Vivek Bhati 500000 2014-06-11 09:00:00 Admin
006 Vipul Diwan 200000 2014-06-11 09:00:00 Account
007 Satish Kumar 75000 2014-01-20 09:00:00 Account
008 Geetika Chauhan 90000 2014-04-11 09:00:00 Admin

Sample Table – Bonus


WORKER_REF BONUS_DATE BONUS_AMOUN
_ID T

1 2016-02-20 5000
00:00:00
2 2016-06-11 3000
00:00:00
3 2016-02-20 4000
00:00:00
1 2016-02-20 4500
00:00:00
2 2016-06-11 3500
00:00:00

Sample Table – Title


WORKER_REF WORKER_TITLE AFFECTED_FROM
_ID

1 Manager 2016-02-20
00:00:00
2 Executive 2016-06-11
WORKER_REF WORKER_TITLE AFFECTED_FROM
_ID

00:00:00
8 Executive 2016-06-11
00:00:00
5 Manager 2016-06-11
00:00:00
4 Asst. Manager 2016-06-11
00:00:00
7 Executive 2016-06-11
00:00:00
6 Lead 2016-06-11
00:00:00
3 Lead 2016-06-11
00:00:00

Q-1. Write an SQL query to fetch “FIRST_NAME” from the


Worker table using the alias name <WORKER_NAME>.

Q-2. Write an SQL query to fetch “FIRST_NAME” from the


Worker table in upper case.

Q-3. Write an SQL query to fetch unique values of


DEPARTMENT from the Worker table.

Q-4. Write an SQL query to print the first three


characters of FIRST_NAME from the Worker table.

Q-5. Write an SQL query to find the position of the


alphabet (‘a’) in the first name column ‘Amitabh’ from
the Worker table.
Q-6. Write an SQL query to print the FIRST_NAME from
the Worker table after removing white spaces from the
right side.

Q-7. Write an SQL query to print the DEPARTMENT from


the Worker table after removing white spaces from the
left side.

Q-8. Write an SQL query that fetches the unique values


of DEPARTMENT from the Worker table and prints its
length.

Q-9. Write an SQL query to print the FIRST_NAME from


the Worker table after replacing ‘a’ with ‘A’.

Q-10. Write an SQL query to print the FIRST_NAME and


LAST_NAME from the Worker table into a single column
COMPLETE_NAME. A space char should separate them.

Q-11. Write an SQL query to print all Worker details from


the Worker table order by FIRST_NAME Ascending.

Q-12. Write an SQL query to print all Worker details from


the Worker table order by FIRST_NAME Ascending and
DEPARTMENT Descending.
Q-13. Write an SQL query to print details for Workers
with the first names “Vipul” and “Satish” from the
Worker table.

Q-14. Write an SQL query to print details of workers


excluding first names, “Vipul” and “Satish” from the
Worker table.

Q-15. Write an SQL query to print details of Workers


with DEPARTMENT name as “Admin”.

Q-16. Write an SQL query to print details of the Workers


whose FIRST_NAME contains ‘a’.

Q-17. Write an SQL query to print details of the Workers


whose FIRST_NAME ends with ‘a’.

Q-18. Write an SQL query to print details of the Workers


whose FIRST_NAME ends with ‘h’ and contains six
alphabets.
Ans.

Q-19. Write an SQL query to print details of the Workers


whose SALARY lies between 100000 and 500000.

Q-20. Write an SQL query to print details of the Workers


who joined in Feb’2014.
Q-21. Write an SQL query to fetch the count of
employees working in the department ‘Admin’.

Q-22. Write an SQL query to fetch worker names with


salaries >= 50000 and <= 100000.

Q-23. Write an SQL query to fetch the no. of workers for


each department in descending order.

Q-24. Write an SQL query to print details of the Workers


who are also Managers.

Q-25. Write an SQL query to fetch duplicate records


having matching data in some fields of a table.

Q-26. Write an SQL query to show only odd rows from


a table.

Q-27. Write an SQL query to show only even rows from


a table.

Q-28. Write an SQL query to clone a new table from


another table.
Q-29. Write an SQL query to fetch intersecting records of
two tables.

Q-30. Write an SQL query to show records from one table


that another table does not have.

Q-31. Write an SQL query to show the current date and


time.

You might also like