Chapter 11 - Group Functions

A. True

All group functions ignore NULL values except COUNT(*).
A. True
B. False

C. SUM

To calculate the total amount stored in a numeric column for a group of rows, the __________ function should be used.
A. AVG
B. MAX
C. SUM
D. COUNT

C. DISTINCT

What keyword should be used to include all values, except NULLS.
A. NULL
B. SUM
C. DISTINCT
D. TO_CHAR

C. NVL

To include NULL values, which functions should be used?
A. NULLIF
B. NULL
C. NVL
D. none of the above

SELECT TO_CHAR(AVG(retail-cost), '$999.99') AS "Average Profit";

Which statement will round the result?
A. SELECT TO_CHAR(AVG(retail-cost), '$999.99') AS "Average Profit";
B. SELECT TO_CHAR((retail-cost), '$999.99') AS "Average Profit";
C.SELECT TO_CHAR(AVG(retail-retail), '$999.99') AS "Average Profit";
D. none of the

B. SELECT COUNT(*)
FROM orders;

Which statement will include NULLS in the count?
A. SELECT COUNT (category)
FROM books;
B. SELECT COUNT(*)
FROM orders;
C. all of the above
D. none of the above

A. SELECT COUNT (category)
FROM books;

Which statement will exclude NULLS from the count?
A. SELECT COUNT (category)
FROM books;
B. SELECT COUNT(*)
FROM orders;
C. all of the above
D. none of the above

D. MAX

Which function returns the largest value?
A. SUM
B. AVG
C. MIN
D. MAX

C. FROM, JOINS, WHERE, GROUP BY, SELECT, HAVING

What is the order that databases work from?
A. SELECT, FROM, WHERE, GROUP BY, HAVING
B. FROM, WHERE, JOIN, GROUP BY, HAVING, SELECT
C. FROM, JOINS, WHERE, GROUP BY, SELECT, HAVING
D. SELECT, WHERE, FROM, GROUP BY, HAVING, JOIN

B. 2

The maximum nesting depth is?
A. 1
B. 2
C. 3
D. 4

C

Which of the following statements is true?
A. The MIN function can be used only with numeric data.
B. The MAX function can only be used with date values.
C. The AVG function can be used only with numeric date.
D. The SUM function can't be part of a nest f

A

Which of the following is a valid SELECT statement?
A. SELECT AVG (retail-cost)
FROM books
GROUP BY category;
B. SELECT category, AVG(retail-cost)
FROM books;
C. SELECT category, AVG(retail-cost)
FROM books;
WHERE AVG(retail-cost) >8.56
GROUP BY category;

D

Which of the following statements is correct?
A. The WHERE clause can contain a group function only if the function isn't also listed in the SELECT clause.
B. Group functions can't be used in the SELECT, FROM, or WHERE clause.
C. The HAVING clause is alwa

A

Which of the following is not a valid SQL statement?
A. SELECT MIN (pubdate)
FROM books
GROUP BY category
HAVING pubid-4;
B. SELECT MIN (pubdate)
FROM books
WHERE category='COOKING';
C. SELECT COUNT(*)
FROM orders
WHERE customer#=1005;
D. SELECT MAX (COUN

a

Which of the following statements is correct?
A. The COUNT function can be used to determine how many rows contain a NULL value.
B. Only distinct values are included in group functions, unless the ALL keyword is included in the SELECT clause.
C. The HAVIN

b

Which of the following is a valid SQL statement?
A. SELECT customer#, order#, MAX(shipdate-orderdate)
FROM orders
GROUP BY customer#
WHERE customer #=1001;
B. SELECT customer#, COUNT(order#)
FROM orders
GROUP BY customer#;
C. SELECT customer#, COUNT(order

D

Which of the following SELECT statements lists only the book with the largest profit?
A. SELECT title, MAX(retail-cost)
FROM books
GROUP BY title;
B. SELECT title, MAX(retail-cost)
FROM books
GROUP BY title
HAVING MAX (retail-cost);
C. SELECT title, MAX(r

E

Which of the following is correct?
A. A group function can be nested inside a group function.
B. A group function can be nested inside a single-row functions.
C. A single-row function can be nested inside a group function.
D. a and b
E. a, b, and c

d

Which of the following functions is used to calculate the total value stored in a specified column?
A. COUNT
B. MIN
C. TOTAL
D. SUM
E. ADD

A

Which of the following SELECT statements lists the highest retail prices of all books in the FAMILY category?
A. SELECT MAX (retail)
FROM books
WHERE category='FAMILY';
B. SELECT MAX (retail)
FROM books
HAVING category='FAMILY';
C. SELECT retail
FROM book

B

Which of the following functions can be used to include NULL values in calculations?
A. SUM
B. NVL
C. MAX
D. MIN

A

Which of the following is not a valid statement?
A. You must enter the ALL keyword in a group function to include all duplicate values.
B. The AVG function can be used to find the average calculated difference between two dates.
C. the MIN and MAX functio

B

Which of the following SQL statements determines how many total customers were referred by other customers?
A. SELECT customer#, SUM(referred)
FROM customers
GROUP BY customer#;
B. SELECT COUNT (referred)
FROM customers;
C. SELECT COUNT(*)
FROM customers;

B

Use the following SELECT statement to answer:
1- SELECT customer#, COUNT(*)
2- FROM customers JOIN orders USING (customer#)
3- WHERE orderdate > '02-APR-09'
4- GROUP BY customer#
5- HAVING COUNT(*) >2;
Which line of the SELECT statement is used to restric

D

Use the following SELECT statement to answer:
1- SELECT customer#, COUNT(*)
2- FROM customers JOIN orders USING (customer#)
3- WHERE orderdate > '02-APR-09'
4- GROUP BY customer#
5- HAVING COUNT(*) >2;
Which line of the SELECT statement is used to restric

.

Use the following SELECT statement to answer:
1- SELECT customer#, COUNT(*)
2- FROM customers JOIN orders USING (customer#)
3- WHERE orderdate > '02-APR-09'
4- GROUP BY customer#
5- HAVING COUNT(*) >2;
Which line of the SELECT statement is used to group d

.

Use the following SELECT statement to answer:
1- SELECT customer#, COUNT(*)
2- FROM customers JOIN orders USING (customer#)
3- WHERE orderdate > '02-APR-09'
4- GROUP BY customer#
5- HAVING COUNT(*) >2;
Because the SELECT statement clause contains the Cust

.

Use the following SELECT statement to answer:
1- SELECT customer#, COUNT(*)
2- FROM customers JOIN orders USING (customer#)
3- WHERE orderdate > '02-APR-09'
4- GROUP BY customer#
5- HAVING COUNT(*) >2;
The COUNT(*) function in the SELECT clause is used to

C

Which of the following functions can be used to determine the earliest ship date for all orders recently processed by JustLee Books?
A. COUNT function
B. MAX function
C. MIN function
D. STDDEV function
E. VARIANCE function

.

Which of the following is not a valid SELECT statement?
A. SELECT STDDEV (retail)
FROM books;
B. SELECT AVG (SUM(retail))
FROM orders
NATURAL JOIN orderitems NATURAL JOIN books
GROUP BY customer#;
C. SELECT order#, TO_CHAR(SUM(retail), '999.99')
FROM orde