Summarizing Data Results from a SQL Query

• Print
This chapter is from the book

Workshop

The following workshop is composed of a series of quiz questions and practical exercises. The quiz questions are designed to test your overall understanding of the current material. The practical exercises are intended to afford you the opportunity to apply the concepts discussed during the current hour, as well as build upon the knowledge acquired in previous hours of study. Please take time to complete the quiz questions and exercises before continuing. Refer to Appendix C, "Answers to Quizzes and Exercises," for answers.

Quiz

1. True or false: The AVG function returns an average of all rows from a select column including any NULL values.

2. True or false: The SUM function is used to add column totals.

3. True or false: The COUNT(*) function counts all rows in a table.

4. Will the following SELECT statements work? If not, what will fix the statements?

1. ```SELECT COUNT *
FROM EMPLOYEE_PAY_TBL;```
2. ```SELECT COUNT(EMPLOYEE_ID), SALARY
FROM EMPLOYEE_PAY_TBL;```
3. ```SELECT MIN(BONUS), MAX(SALARY)
FROM EMPLOYEE_PAY_TBL
WHERE SALARY > 20000;```

Exercises

1. Use EMPLOYEE_PAY_TBL to construct SQL statements to solve the following exercises:

1. What is the average salary?

2. What is the maximum bonus?

3. What are the total salaries?

4. What is the minimum pay rate?

5. How many rows are in the table?

2. How many employees do we have whose last names begin with a G?

3. If every product cost \$10.00, what would be the total dollar amount for all orders?