Practice with dates
Try the following problems on the HR schema in SQL Developer. Use the Oracle documentation when you need help with SQL functions.
-
Display the date that each employee was hired so that you can see the associated time component. What does the data tell you about the way the date values were inserted?
-
Display the name of each employee and the year they were hired
-
Modify the previous query to show the number of employees hired in each year (Requires an aggregate function)
-
Display the name of each employee and the date of their first salary payment (This will be the last day of the month in which they were hired)
-
For each employee, display their name and list all the positions they have held in the company showing start and end dates.
-
Modify the previous query so that results also display the number of months that each position lasted rounded to the nearest whole number of months. (Requires the use of two functions - get the date part working first, then do the formatting)
-
Display the names of all employees and their length of service in months starting with the person who has worked for the company the longest. (Do the ordering last - get everything else working first)
-
Find the names of all employees hired since 1st January 2000
-
Find the names of all employees hired between 1990 and 1999 (inclusive)
-
Display the name of each employee and the title of their first job with the company. (Use a subquery to get the employee's earliest start date)