Você está na página 1de 3

Employee Database

EMP:
EMPNO ENAME
JOB
MGR
7369 SMITH
CLERK
7902
7499 ALLEN
SALESMAN 7698
7521 WARD
SALESMAN 7698
7566 JONES
MANAGER 7839
7654 MARTIN SALESMAN 7698
7698 BLAKE
MANAGER 7839
7782 CLARK
MANAGER 7839
7788 SCOTT
ANALYST 7566
7839 KING
PRESIDENT
7844 TURNER SALESMAN 7698
7876 ADAMS CLERK
7788
7900 JAMES
CLERK
7698
7902 FORD
ANALYST
7566
7934 MILLER CLERK
7782

HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
19-APR-87
17-NOV-81
08-SEP-81
23-MAY-87
03-DEC-81
03-DEC-81
23-JAN-82

DEPT:
DEPTNO
10
20
30
40

DNAME
ACCOUNTING
RESEARCH
SALES
OPERATIONS

LOC
NEW YORK
DALLAS
CHICAGO
BOSTON

SALGRADE:
GRADE
1
2
3
4
5

LOSAL
700
1201
1401
2001
3001

HISAL
1200
1400
2000
3000
9999

CYCLE - 02

SAL COMM
800
1600 300
1250 500
2975
1250 1400
2850
2450
3000
5000
1500
0
1100
950
3000
1300

DEPTNO
20
30
30
20
30
30
10
20
10
30
20
30
20
10

Problem NO: 01
STATEMENT: BASIC QUERIES ON EMPLOYEE, DEPARTMENT TABLES
USING BUILT-IN FUNCTIONS.
1. Display the department names in the lower case but the initial must be in uppercase.
2. Determine the ename, job, sal rename the title as Job-sal the output must be
Job-Sal as SMITH[CLERKRS.2000]
3. Count the number of times S occurs in department names.
4. Write a query to display the department name which does not contains any employees.
5. Write a query to display all employee details where employee was joined during the
years 1980 to 1990 and in the 2nd week of a month
6. Write an SQL statement to convert the current date to new date picture
ex: MONDAY 10th 2005 10:30.00 PM
7. Write a query to display details of all employees who joined on last Monday of a
month and whose experience is more than 20 months.
8. Write a query to calculate the service of employees rounded to years.
9. Write a query that will display all different job types.
10. Write a query that will display list of employees and their salary and the comments as
follows.
If the salary is more than 1500 then display above target
If the salary is equal to 1500 then display on the target
If the salary is less than 1500 then display below the target
11. Display all employee names, employee number, department names & salary grades
for all employees who are working in department 30.
12. Display the time of day.

Problem NO: 02
STATEMENT: QUERIES WITH GROUP FUNCTIONS AND NESTED QUERIES.

1
2
3
4
5
6
7
8
9
10
11
12
13

Find all employees who earn a salary greater than the average salary of their
departments.
Write a query to sort names of employees in department 10 & 20 in alphabetical order
Write a query to display all job types.
Calculate the number of employees and average salary of each department.
Write a query to find the name of the manager and number of sub-ordinates.
Write a query to find out the manager having Maximum number of sub-ordinates.
(a) Write a query to find out the top three earners.
(b) Write a query to find out the least three earners.
Display the average, monthly salary bill for each job type with in department.
Find all employees whose dept is not in dept table.
(a) Write a query to find out the employees who have joined before their managers.
(b) Write a query to find out the year, where most people join in the company displays
the year and No. of Employees.
(a) List the department names of each employee.
(b) Find all employees who earn lowest salary in each department.
(a) Display all employees who earn more than the lowest salary of department 30.
(b) Display all departments, which have the average salary more than average salary
of department.
Write a query which will return the DAY of the week. (i.e. MONDAY), for any date
entered in the format: DD.MM.YY.