Now You Try It
The Human Resources department would like to know how many different types of skills there are in the company. Enter the appropriate statement to determine the total number of skills in the SKILL table.
The result looks like this:
(EXPR) ------ 26 1 row processed
If your results do not match what you see above, check Review Answers for Chapter 5 for the correct SQL syntax.
Specifying a Column Name with COUNT
If you specify a column name with COUNT, only the rows containing a value in that column are counted.
How It's Done
Human Resources has made another request. They would like to know how many employees have telephones in their homes. You can comply with this request by creating a SELECT statement using COUNT and the column name PHONE from the EMPLOYEE table:
select count(phone)
from employee;
The result looks like this:
(EXPR) ------ 49 1 row processed
There were fewer rows returned with this request than there were when you specified COUNT(*). This time, COUNT counted only the rows that had a telephone number. It did not count the rows that contain a null value for PHONE. When you used COUNT(*), all rows are counted.
|
Copyright © 2014 CA.
All rights reserved.
|
|