

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Sql queries to extract various insights from an employees table, including months worked, dream salaries, salary formatting, salary review dates, day of hire, commission amounts, and annual salaries with asterisks. The queries are ordered and formatted for easy understanding.
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


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.
SELECT LAST_NAME,ROUND(MONTHS_BETWEEN(SYSDATE,HIRE_DATE)) AS "MONTHS_WORKED" FROM EMPLOYEES ORDER BY MONTHS_WORKED;
salary>. Label the column Dream Salaries.
SELECT LAST_NAME,SALARY,(SALARY*3) AS "DREAM SALARY" FROM EMPLOYEES;
characters long, left-padded with $. Label the column SALARY.
SELECT LAST_NAME,LPAD(SALARY,15,'$') AS "SALARY" FROM EMPLOYEES;
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.”
WITH E1 AS (SELECT LAST_NAME,HIRE_DATE,ADD_MONTHS(HIRE_DATE,6) AS "REVIEW_DATE" FROM EMPLOYEES)
SELECT LAST_NAME,HIRE_DATE,TO_CHAR((NEXT_DAY(REVIEW_DATE,'MONDAY')),'DAY') AS "DAY",NEXT_DAY(REVIEW_DATE,'MONDAY') AS "SALARY REVIEWED DATE" FROM E1 ;
the column DAY. Order the results by the day of the week starting with Monday.
SELECT LAST_NAME,HIRE_DATE,TO_CHAR(HIRE_DATE,'DAY') AS "DAY" FROM EMPLOYEES ORDER BY DAY ASC;
employee does not earn commission, put “No Commission.” Label the column COMM.
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.