ORACLE SQL - Scenerio Based Part 1 Quest

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ASSIGNMENT-1

1.Using the DECODE function, write a query that displays the grade of all
employees based on the value of the column JOB_ID, as per the following
data:

2. Create a query that displays the employees’ last names and indicates the
amounts of their annual salaries with asterisks. Each asterisk signifies a
thousand dollars. Sort the data in descending order of salary. Label the
column EMPLOYEES_AND_THEIR_SALARIES. 

3. Create a query that displays the employees’ last names and commission
amounts. If an employee does not earn commission, put “No Commission.”
Label the column COMM.

4.
Create a query that displays the employees’ last names and commission
amounts. If an employee does not earn commission, put “No Commission.”
Label the column COMM.

5. Display the last name, hire date, and day of the week on which the
employee started. Label the column DAY. Order the results by the day of the
week starting with Monday. 

6. Display each employee’s last name, hire date, and salary review date,
which is the first Monday after six months of service. Label the column
REVIEW. Format the dates to appear in the format similar to “Monday, the
Thirty-First of July, 2000.”

7.
Create a query to display the last name and salary for all employees.
Format the salary to be 15 characters long, left-padded with $. Label the
column SALARY. 

8. Write a query that produces the following for each employee: <employee
last name> earns <salary> monthly but wants <3 times salary>. Label the
column Dream Salaries.

10. For each employee, display the employee’s last name, and calculate the
number of months between today and the date the employee was hired. Label
the column MONTHS_WORKED. Order your results by the number of months
employed. Round the number of months up to the closest whole number.

11. Write a query that displays the employee’s last names with the first
letter capitalized and all other letters lowercase, and the length of the
names, for all employees whose name starts with J, A, or M. Give each
column an appropriate label. Sort the results by the employees’ last names.
ASSIGNMENT-1

12.Modify your query lab3_2.sql to add a column that subtracts the old
salary from the new salary. Label the column Increase. Save the contents of
the file as lab3_4.sql. Run the revised query. 

13.For each employee, display the employee number, last_name, salary, and
salary increased by 15% and expressed as a whole number. Label the column
New Salary. Place your SQL statement in a text file named lab3_2.sql.

14.Write a query to display the current date. Label the column Date.

15.Difference between WHERE clause and HAVING clause. 

16.Display all the department id and number of employees working in that


department. Total no employees working for the particular department must
be greater than 30.

17.Display all the department id and salary allocated for that department.

18.Display all the department id and number of employees working in that


department.  

19.Display all the department id and its maximum salary.

20.Display number of employees working in department 90 and 60.

21.Display first three characters from first name.

22.
Display last two character from last name.

23. Display all the first name and position of a in that name (first
occurrence of a).

24. Display all the first name and position of a in that name (second
occurrence of a)
ASSIGNMENT-1

25. Display all the name which contain two or more number of a 's in the
first name.

26. Display first three characters from first name.

27.Display last two character from last name.

28.Display all the first name and position of a in that name (first
occurrence of a).    

29.Display all the first name and position of a in that name (second
occurrence of a)

You might also like