You are on page 1of 6

SQL QUERIES

1. List all information about the employees in the Emp Table.

2. List all information about the Departments in the Dept Table.

3. List the employee number, name, Job title and Hiredate of employee in department 10.

4. Select the name and salary of all employees who are clerks.

5. Select the name and annual salary of all employee

6. List the Name,Job, Salary of everyone Hired in December 17,1980.

7. List the Department Name and Department number for Department with numbers greater
than or equal to 20.

8. List all employees who have a salary between 1000 and 2000.

9. List the names of employees where Salaries are less than 2500.

10. Select the name,salary and commission of employees where commission is greater than their
salary.

11. Display the name,monthly salary,daily salary and Hourly salary for employees.Assume that
the Sal column in the table is the monthly salary,that there are 22 working days in a
month,and that there are 8 working hours in a day.Rename the columns as monthly,daily and
hourly.

12. List the names and employers numbers of managers who earn more than 2600 display in
Alphabetic order by name.

13. Display all employees names which have TH or LL in them.

14. List the details of the employees in Departments 10 and 20 in alphatical order of Name.

15. Select the information about manager and the president from the column job in the table
emp.Order the result by department number.

16. List the employee names that donot end with “S”.

17. List the employee names that starts with “C”.

18. List the name,job and department of everyone whose name falls in the Alphabetic range “C”
To “F”.
19. List employees details working in department 20,30 or 40.
20. List of employees whose names start with “T” and end with “R”.

21. Display all employees who were hired in 1990.

22. List all rows from Emp table, by converting the null values in comm Column to 0.

23. List all managers and salesman with salaries over Rs. 1500

24. List of employees who do not get any commission.

25. Show what length names appears in the emp table.Eliminate,Duplicate lengths from the rows
returned.Do not show the names themselves.

26. List the names and hire dates of the employees in Dept 20 Display hire date formatted as
‘12/03/84’.

27. How many months has the president worked for the company? Round nearest whole number
of months.

28. List the names of all employees whose hire date anniversary is in the month of December.

29. Give SQL command to find the average salary per job in each Dept.This SQL figures in Emp
table are for each month.

30. In one Query,count the number of people in Dept. No.30 who can receive a salary and the
number of people who receive a commission.

31. Compute the average,minimum and maximum salaries of those groups of employees having
the job clerk or manager.

32. Calculate the total compensation expense for each Dept.for one year,the SQL comm figure
in the Emp table are for each month.Assume that employees who donot earn a commission
receive non-monetory benefits that are worth $ 100.00 a month.

33. Do a case insensitive search for a list of employees with a job that a user enters (e.g. clerk).

34. Produce the following output


Employee
Smith(clerk)

35. Which employees earn less than 30% of the President’s salary.

36. Who was the last employee hired in each department.

37. Create a view consisting of number of employees and their total sum of salary grouped by
Dept No.wise.
38. Create a view consisting of all the columns from Emp Table and their corresponding records
from Dept.Table consisting of Dname & location.

39. How many employees work in the Newyork.

40. Which employees work in Newyork.

41. Write a query to display as following


Ename Date-Hired
Smith June Fourteenth 1983

42. Print a list of employees displaying just salary if more than 1500. ‘If exactly 1500 Display
“ON TARGET”. If less than 1500 Display “BELOW TARGET”.

43. List the employee names and the cited in which they work order by City.

44. Find the number of different employees and the number of Depts.

45. Determine the average salaries of employees

46. List the Department number,Department name,Location and Local commission paid and total
salary of each department.

47. Display the average monthly salary bill for eachjob Type within a Department.

48. To Display only those Jobs where the minimum salary is greater than or equal to 3000.

49. Find out the difference between highest and lowest salaries.

50. Find all Depts. Which have more than 3 employees.

51. Check whether all employee numbers are indeed unique.

52. List lowest paid employees working for each manager.

53. Display all employee names and their department names in department name order.

54. Display all employee name,Department number and name.

55. Display the Department that has no employee.

56. Find all employees who joined the company before their manager

57. Find all employees who have same Job as Black.

58. Find the employees who earn more than the lowest salary in each department.
59. Display employees who earn more than the lowest salary in Dept No.30.

60. Find Employees who earn more than every employee in Dept No. 30.

61. Find the job with the highest average salary.

62. Display the Name,Job,Hiredate for employees whose salary is greater than the highest salary
in any sales dept.

63. Copy all inforamtion on department 10 into the D10 History table.

64. Delete all information about Department 10 from Employee table.

65. Create on Cluster table/Cluster Index on Emp(Dept No) and Dept(Dept No).

66. Create Indes on Emp No. on Emp Table

67. List all tables which are created on a particular date

68. List all Indexes which are created on a particular date and table.

69. List all views which are created on particular date and table.

70. List all synonyms which are created for a particular table and date.

71. List all the objects which are created on a particular date.

72. To Display an Asterick against the row the most recently hired employees.Display
Ename,Hiredate,and Column showing “*” and Column name maxdate(for unique records)

73. Delete the rows from Dept Table whose Dept No numbers does not matching rows in the
Emp database.

74. Select Ename,Job,Sal,MGR,Dept No for a given jobn title.

75. List the employee name and Salary increased by 15% and expressed as a whole number of
dollars.

76. Display each employees name with hiredate,and review date.Assume review date is one year
after hiredate.Order the output in ascending review date order.

77. Write a Query which will return the day of the week,for any date entered in the format
DD.MM.YY.
78. Employees hired on or before the 15th of any Month are paid on the last Friday of that
Month.Those hired after the 15th are paid the last Friday of the following Month.Print a list of
employees,their hiredate and first Pay date.Sort on hire dates.

79. List the Minimum and Maximum salary for each Job type.

80. Find the average salary and average total renumeration for each job type.Remember
salesman earn commission.

81. Find all departments which have max than 3 employees.

82. List the employee name,Job,Salary,grade and department name for everyone in the company
except clerks,Sort on Salarydisplaying the highest salary first.

83. List the Ename,Job,Annual-Sal,Dept no.,Dname,Grade of employees who earn $36000 a year
or who are clerks.

84. Show Ename,Salary,Dept no for any employee who earns a salary greater than the average
for their department sort in department number order.

85. Who are the top 3 earners in the company? Display their name and salary.

86. In which year did most people join the company? Display the year and number of employees.

87. Find employees who earn a salary greater than the average salary for their department.

88. Find all employees whose department is not in the Dept table.

89. It has been discovered that the sales people in dept 30 are not all males produce the following
output.
NAME DEPT NO JOB
ALLEN 30 Sales Person
WARD 30 Sales Person
BLAKE 30 Manager

90. Find the employee who earns the minimum salary.

91. Display the name,Job,Hiredate,Sal for employees whose salary is greater than the highest
salary in Sales Dept.

92. List Employees with either the same Job as Jones or a salary greater than or equal to
Ford’s.In order by Job and salary.

93. List employees in Department 10 with the same job as anyone in the sales department.

94. List the employees having the same job as employees located in Chicago.
95. List employees whose salary is equal to that of SCOTT or WARD.

96. Set salaries of all salesman equal to 1.1 times the average salary of salesman.

97. Delete all employees with the same job as JONES and Jones should not be deleted

You might also like