SQL1
SQL1
Programmers are known to consume large amounts of caffeinated drinks. The owner of a small
independant software dev company is particularly concerned with the number of cups of coffee
that his employees consume on a daily basis.
The CoffeeLogs table contains a log of the number of cups of coffee that are consumed by
individual employees.
Open the database and study the table’s design, then write SQL statements for the following:
2) Extract all records and all fields, sorted in ascending order by LastName.
3) Extract all records and all fields, sorted in descending order by the number of cups
consumed per day.
4) Retrieve all of the records for Henry Black. Ensure that the output looks similar to
the example output below.
EXAMPLE OUTPUT
5) Ensure that all records and all fields are shown for entries where the number of
cups consumed is more than 6.
EXAMPLE OUTPUT
PAGE 2 OF 3
6) Retrieve the records where the number of cups consumed is more than or equal to
10, sorted in descending order by the number of cups consumed. Only the last
name, date and CupsConsumed fields must be shown.
EXAMPLE OUTPUT
7) An erroneous entry has been detected. Update the record of Gilbert Black where
the CupsConsumed value is 31 to 13.
8) Display the first name and last name of all employees. Each employee should only
be shown ONCE.
EXAMPLE OUTPUT
9) Display the average number of cups consumed per day for all employees. Call the
calculated field AVERAGE.
EXAMPLE OUTPUT
PAGE 3 OF 3
10) Display the number of collective cups of coffee consumed in the CoffeeLogs
table. Call the new field TOTAL CUPS CONSUMED.
EXAMPLE OUTPUT