CA204 DBMSLab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Consider the following tables:

emp(empno,ename,job,mgr,hiredate,sal,comm,deptno),

dept(deptno,dname,loc)

Write the following queries:

1. List all information about all department from emp table.

2. List all employee names along with their salaries from emp table.

3. List all department numbers, employee numbers and their managers numbers in descending

order of deptno from emp table.

4. List department names and locations from the dept table.

5. List the employees belonging to the department 20.

6. List the name and salary of the employees whose salary is more than 1000.

7. List the names of the clerks working in the department 20.

8. List the names of analysts and salesmen.

9. List the details of the employees who have joined before the end of September 81.

10. List the names of employees who are not managers.

11. List the names of employees whose employee number are 7369, 7521, 7839, 7934, 7788.

12. List the employee details not belonging to the department 10, 30, and 40.

13. List the employee name and salary, whose salary is between 1000 and 2000.

14. List the employee names, who are not eligible for commission.(salary having >15,000 eligible

for commission)

15. List the employees who are eligible for commission.

16. List the details of employees, whose salary is greater than 2000 and commission is NULL.

17. List the employees whose names start with an “S” (not”s”).

18. List the name, salary and PF amount of all the employees(PF is calculated as 10% of salary).

19. List the empno, ename, sal in ascending order of salary.

20. List the employee name, salary, job and Department no descending order of Department No

and salary.

21. List the employee details in ascending order of salary.

22. List the employee details in descending order of salary

23.Display name, and sal and commission of all employees whose monthly salary is greater

than their commission.


24. Select SMITH HAS WORKED IN THE POSITION OF CLERK IN DEPT 20.Display

result in this format.

25. Generate a statement which prompts the user at runtime. The intention is to display

employees hired between 2 given dates.

26. Define a variable representing an expression used to calculate total annual remuneration. Use

the variable in a statement which finds all employees who earn $30000 a year or more.

27. List all the employees name and salaries increased by 15% and expressed as a whole

number of dollars.

28.Produce the following

Page 75 of 243

EMPLOYEE AND JOB

SMITH CLERK

ALLEN SALESMAN

29. Produce the following output:

SMITH ( Clerk)

ALLEN ( Salesman)

30. Do a case sensitive search for a list of employees with a job that the user enters.

31. It has been discovered that the sales people in dept. 30 are not all male. Please produce the

Followingoutput.

ENAME DEPTNO JOB

ALLEN 30 Sales Person

32. Display each employees name and hiredate of dept 20.

33. Display each employees name, hiredate and salary review date. Assume salary review date

is one year from hiredate. Output should be in ascending re view date.

34. Print list of employees displaying just salary, if more than 1500. If exactly 1500 display “ On

Target”. If less than 1500 display “ Below 1500”.

35. Write a query which returns DAY of the week ( i.e. MONDAY) for any date entered in the

format DD/MM/YY.

36. Write a query to calculate length of service of each employee.

37. Find the minimum salary of all employees.

38. Find the maximum, minimum, and average salaries of all employees.
39. List the maximum and minimum salary of each job type.

40. Find how many managers are in each dept.

41. Find the average salary and average total remuneration of each job type. Remembers sales man

earn commission.

42. Find out the difference between highest and lowest salary.

43. Find all department s which have more than three employees.

44. Check whether all employee nos are unique. ( No Duplicate)

45. List lowest paid employee working for each Manager. Exclude any groups where the minimum

salary is less than 1000. Sort the output by salary.

46. Produce a list showing employees ‘salary grade’.(> 10000 A, >10000 &<20000 B, >20000 C)

47. Show only employee on Grade C.

48. Show all employee in Dallas.

49. List the employees name, job, salary, grade and department for everyone in the company except

clerks. Sort on salary, displaying the highest first.

50. List the following details of employees who earn $36000 a year or who are clerks.

Ename Job Annual Sal Dept no Dname Grade

51. Display all employees who earn less than their managers.

52. Display all employees by name and eno along with their managers name and number.

53. Modify above spoliation to display KING who has no MANAGER.

54. Find the job that was files in the first half of 1983 and the name job that was filled in the same

period in 1984.

55. Find all employees who have joined before their manager.

EMPLOYEE HIREDATE MANAGER HIREDATE

Page 76 of 243

56. Find the employees who earn the highest salary in each job, type, sort in descending order

of salary.

57. Find the employees who earn the minimum salary for their job, Display the result in

descending order of salary

58. Find the most recently hired employees in the department. Order by hiredate.

59. Show the details of any employee who earns a salary greater than the average for their
department. Sort in department number order.

60. List all department where there are no employee

You might also like