Database Programming With SQL Section 8 Quiz
Database Programming With SQL Section 8 Quiz
1. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the
following? Mark for Review
(1) Points
2. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
MAX (*)
STDDEV
AVG
SUM
Which two clauses represent valid uses of aggregate functions for this table?
SELECT SUM(order_dt)
FROM MAX(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT MIN(AVG(order_amount)) (*)
4. Group functions return a value for ________________ and ________________ null values in
their computations. Mark for Review
(1) Points
5. Which group function would you use to display the lowest value in the SALES_AMOUNT
column? Mark for Review
(1) Points
COUNT
MAX
AVG
MIN (*)
6. Given the following data in the employees table (employee_id, salary, commission_pct)
DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)
Which SELECT statement will return the average price for the 4x4 model?
SELECT AVG(price)
FROM trucks
WHERE model IS 4x4;
SELECT AVG(price)
FROM trucks
WHERE model IS '4x4';
SELECT AVG(price)
FROM trucks
WHERE model = '4x4';
(*)
8. You need to compute the total salary amount for all employees in department 10. Which group
function will you use? Mark for Review
(1) Points
COUNT
SUM (*)
VARIANCE
MAX
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000;
(*)
The statement will count the number of rows in the INVENTORY table where the AMOUNT
column is not null. (*)
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will return the greatest value in the INVENTORY table.
12. To include null values in the calculations of a group function, you must: Mark for Review
(1) Points
13. Which statement about the COUNT function is true? Mark for Review
(1) Points
14. Which SELECT statement will calculate the number of rows in the PRODUCTS table?
Mark for Review
(1) Points
15. Using your existing knowledge of the employees table, would the following two statements
produce the same result?
SELECT COUNT(*)
FROM employees;
SELECT COUNT(commission_pct)
FROM employees;
Mark for Review
(1) Points
Which SELECT statement will return the average price for the 4x4 model?
SELECT AVG(price)
FROM trucks
WHERE model IS 4x4;
SELECT AVG(price)
FROM trucks
WHERE model IS '4x4';
SELECT AVG(price)
FROM trucks
WHERE model = '4x4';
(*)
2. Which group function would you use to display the highest salary value in the EMPLOYEES
table? Mark for Review
(1) Points
MIN
MAX (*)
AVG
COUNT
3. You need to compute the total salary amount for all employees in department 10. Which group
function will you use? Mark for Review
(1) Points
SUM (*)
MAX
VARIANCE
COUNT
4. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
AVERAGE
MEDIAN
MEAN
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date
BETWEEN '01-Jan-2003' AND '31-Mar-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (Jan, Feb, Mar);
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-Jan-2003' and '31-Mar-2003';
6. Which group function would you use to display the lowest value in the SALES_AMOUNT
column? Mark for Review
(1) Points
MIN (*)
MAX
COUNT
AVG
7. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the
following? Mark for Review
(1) Points
Integers only
Only numeric data types (*)
Any data type
All except numeric
8. Which group function would you use to display the total of all salary values in the EMPLOYEES
table? Mark for Review
(1) Points
COUNT
MAX
AVG
SUM (*)
The statement will return the greatest value in the INVENTORY table.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will return the total number of rows in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT
column is not null. (*)
11. Group functions can avoid computations involving duplicate values by including which
keyword? Mark for Review
(1) Points
DISTINCT (*)
SELECT
UNLIKE
NULL
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
SELECT COUNT(*)
FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
13. Which statement about the COUNT function is true? Mark for Review
(1) Points
14. Which SELECT statement will calculate the number of rows in the PRODUCTS table?
Mark for Review
(1) Points
SELECT COUNT(category)
FROM styles;
7 (*)
6
The statement will NOT execute successfully.