SQL Assignment 1
SQL Assignment 1
SQL Assignment 1
Download SQL Database file and read the document to add database to My SQL and then complete the project.
HR Database Exercises –
1. Write a query to display the names (first_name, last_name) using alias name “First Name", "Last
Name"
2. Write a query to get unique department ID from employee table
3. Write a query to get all employee details from the employee table order by first name, descending
4. Write a query to get the names (first_name, last_name), salary, PF of all the employees (PF is
calculated as 15% of salary)
5. Write a query to get the employee ID, names (first_name, last_name), salary in ascending order of
salary
6. Write a query to get the total salaries payable to employees
7. Write a query to get the maximum and minimum salary from employees table
8. Write a query to get the average salary and number of employees in the employees table
9. Write a query to get the number of employees working with the company
10. Write a query to get the number of jobs available in the employees table
11. Write a query get all first name from employees table in upper case
12. Write a query to get the first 3 characters of first name from employees table
13. Write a query to get first name from employees table after removing white spaces from both side
14. Write a query to get the length of the employee names (first_name, last_name) from employees table
15. Write a query to check if the first_name fields of the employees table contains numbers
16. Write a query to display the name (first_name, last_name) and salary for all employees whose salary is
not in the range $10,000 through $15,000
17. Write a query to display the name (first_name, last_name) and department ID of all employees in
departments 30 or 100 in ascending order
18. Write a query to display the name (first_name, last_name) and salary for all employees whose salary is
not in the range $10,000 through $15,000 and are in department 30 or 100
19. Write a query to display the name (first_name, last_name) and hire date for all employees who were
hired in 1987
20. Write a query to display the first_name of all employees who have both "b" and "c" in their first name
21. Write a query to display the last name, job, and salary for all employees whose job is that of a
Programmer or a Shipping Clerk, and whose salary is not equal to $4,500, $10,000, or $15,000
22. Write a query to display the last name of employees whose names have exactly 6 characters
23. Write a query to display the last name of employees having 'e' as the third character
24. Write a query to get the job_id and related employee's id
Partial output of the query :
job_id Employees ID
AC_ACCOUNT 206
AC_MGR 205
AD_ASST 200
AD_PRES 100
AD_VP 101 ,102
FI_ACCOUNT 110 ,113 ,111 ,109 ,112
25. Write a query to update the portion of the phone_number in the employees table, within the phone
number the substring '124' will be replaced by '999'
26. Write a query to get the details of the employees where the length of the first name greater than or
equal to 8
27. Write a query to append '@example.com' to email field
28. Write a query to extract the last 4 character of phone numbers
29. Write a query to get the last word of the street address
30. Write a query to get the locations that have minimum street length
31. Write a query to display the first word from those job titles which contains more than one words
32. Write a query to display the length of first name for employees where last name contain character 'c'
after 2nd position
33. Write a query that displays the first name and the length of the first name for all employees whose
name starts with the letters 'A', 'J' or 'M'. Give each column an appropriate label. Sort the results by the
employees' first names
34. Write a query to display the first name and salary for all employees. Format the salary to be 10
characters long, left-padded with the $ symbol. Label the column SALARY
35. Write a query to display the first eight characters of the employees' first names and indicates the
amounts of their salaries with '$' sign. Each '$' sign signifies a thousand dollars. Sort the data in
descending order of salary
36. Write a query to display the employees with their code, first name, last name and hire date who hired
either on seventh day of any month or seventh month in any year
Northwind Database Exercises-