This page provides exercises and solutions to help you practice SQL SELECT statements. These exercises are based on the HR database, and may be performed online or by running the sample schema scripts on your local database server. For additional exercises in other subjects, use this link.
 

Basic SELECT statements – Exercises

  1. Create a query to display all the data from the Employees table.
  2. The following SELECT statement executes successfully (True / False)
FROM employees
SELECT last_name, first_name
  1. Create a query to display the department number, department name, and manager number. Name the last column (manager number) heading as “MNG” (Employees table).
  2. The following SELECT statement executes successfully (True / False)
SELECT department_name, department_name
FROM departments
  1. The following SELECT statement executes successfully (True / False)
SeleCT last_NAME, fiRST_NamE, FROM Employees
  1. Create a query to display the employee number, first name, last name, phone number and department number (Employees table).
  2. Create a query to display the first name, last name, hire date, salary, and salary after a raise of 20%. Name the last column (salary after a raise) heading as “ANNUAL_SAL” (Employees table).
  3. Create a query to display the last name concatenated with the first name, separated by space, and the telephone number concatenated with the email address, separated by hyphen. Name the column headings “FULL_NAME” and “CONTACT_DETAILS” respectively (Employees tables).
  4. Create a query to display the unique manager numbers from Employees table.
  5. Create a query to display the last name concatenated with job_id column, separated by space. Name this column heading as “EMPLOYEE_AND_TITLE” (Employees table).
  6. Create a query to display the first name, last name, salary, and hire date concatenated with the literal string “HD”, separated by space. Name the column headings “FN”, “LN”, “SAL”, and “HD” respectively (Employees table).
  7. Create a query to display the unique salaries in Employees tables.
  8. Create a query to display the unique combination of values in department_id and job_id columns (Employees table).