w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display all the information of employees hired before June 21st, 2002

SQL SORTING and FILTERING on HR Database: Exercise-15 with Solution

15. Write a query in SQL to display all the information from Employees table for those employees who was hired before June 21st, 2002.

Sample table: employees


Sample Solution:

SELECT *
 FROM employees
  WHERE hire_date < '2002-06-21';

Sample Output:

employee_id | first_name | last_name |  email   | phone_number | hire_date  |   job_id   |  salary  | commission_pct | manager_id | department_id
-------------+------------+-----------+----------+--------------+------------+------------+----------+----------------+------------+---------------
         102 | Lex        | De Haan   | LDEHAAN  | 515.123.4569 | 2001-01-13 | AD_VP      | 17000.00 |           0.00 |        100 |            90
         203 | Susan      | Mavris    | SMAVRIS  | 515.123.7777 | 2002-06-07 | HR_REP     |  6500.00 |           0.00 |        101 |            40
         204 | Hermann    | Baer      | HBAER    | 515.123.8888 | 2002-06-07 | PR_REP     | 10000.00 |           0.00 |        101 |            70
         205 | Shelley    | Higgins   | SHIGGINS | 515.123.8080 | 2002-06-07 | AC_MGR     | 12000.00 |           0.00 |        101 |           110
         206 | William    | Gietz     | WGIETZ   | 515.123.8181 | 2002-06-07 | AC_ACCOUNT |  8300.00 |           0.00 |        205 |           110
(5 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display all the information of employees hired before June 21st, 2002 - Duration

Rows:

Query visualization of Display all the information of employees hired before June 21st, 2002 - Rows

Cost:

Query visualization of Display all the information of employees hired before June 21st, 2002 - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display the full name (first and last name), salary, and manager number for those employees who is working under a manager.
Next: Write a query in SQL to display the first and last name, email, salary and manager ID, for those employees whose managers are hold the ID 120, 103 or 145.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming