Course Logo Image

SQL Select Statement Tutorial


Suppose the database table name is "employees" and that database field names are:

  • "first" to contain an employee's first name
  • "last" to contain an employee's last name
  • "id" to contain an employee's company identification number
  • "age" to contain an employee's age
  • "city" to contain an employee's city of residence
  • "state" to contain an employee's state of residence

Answer the following questions by using the SQL Query Tool.

SQL Query requirements Question to Answer
1. Query the database for the first and last name and age of all employees, and show all records in order by age. How many years difference are there between the oldest employee and the youngest employee?
2. Query the database for employee identification number and state of residence, retrieving only the records of people who live in Texas. What is the employee ID number of the employee who lives in Texas?
3. Query the database for employee first and last name, age, and state of residence, retrieving only the records of people who live in California. Who is the oldest employee who lives in California?
4. Query the database for employee first and last name, age, and state of residence, retrieving only the records of people who live in Show Low, Arizona. How old is the employee who lives in Show Low, Arizona?
5. Query the database for employee first and last name and state and city of residence, retrieving only the records of people whose last name is Simon. Where does Carly Simon live?


Copyright 2002 by Gary Kidney