6 Quiz Computer Science

25 July 2022
4.7 (114 reviews)
15 test answers

Unlock all answers in this set

Unlock answers (11)
question
A SELECT statement that includes aggregate functions is often called a/an BLANK query.
answer
summary
question
All of the aggregate functions ignore null values, except for the BLANK function.
answer
COUNT(*)
question
By default, all duplicate values are included in the aggregate calculation, unless you specify the BLANK keyword.
answer
DISTINCT
question
Code example 6-1 SELECT vendor_state, vendor_city, vendor_name, COUNT(*) AS invoice_qty, SUM(invoice_total) AS invoice_average FROM invoices JOIN vendors ON invoices.vendor_id = vendors.vendor_id WHERE vendor_state < 'e' GROUP BY vendor_state, vendor_city, vendor_name HAVING SUM(invoice_total) > 500 ORDER BY vendor_state, vendor_city, vendor_name (Please refer to code example 6-1.) When this summary query is executed, the result set will contain one summary row for each vendor with invoice average over $500 each city with invoice average over $500 each city with invoice totals over $500 each vendor with invoice totals over $500
answer
each vendor with invoice totals over $500
question
Code example 6-1 SELECT vendor_state, vendor_city, vendor_name, COUNT(*) AS invoice_qty, SUM(invoice_total) AS invoice_average FROM invoices JOIN vendors ON invoices.vendor_id = vendors.vendor_id WHERE vendor_state < 'e' GROUP BY vendor_state, vendor_city, vendor_name HAVING SUM(invoice_total) > 500 ORDER BY vendor_state, vendor_city, vendor_name (Please refer to code example 6-1.) Although this query runs as coded, it contains this logical error: The three columns in the ORDER BY clause should use the DESC keyword so the city totals will be in the right sequence. The column name for the fifth column in the result set doesn't match the data. The condition in the WHERE clause should be coded in the HAVING clause. The condition in the HAVING clause should be coded in the WHERE clause.
answer
The column name for the fifth column in the result set doesn't match the data.
question
Expressions coded in the HAVING clause can use non-aggregate search conditions but can't use aggregate search conditions can use aggregate search conditions but can't use non-aggregate search conditions can refer to any column in the base tables can use either aggregate search conditions or non-aggregate search conditions
answer
can use either aggregate search conditions or non-aggregate search conditions
question
Expressions coded in the WHERE clause can use non-aggregate search conditions but can't use aggregate search conditions must refer to columns in the SELECT clause can use either aggregate search conditions or non-aggregate search conditions can use aggregate search conditions but can't use non-aggregate search conditions
answer
can use non-aggregate search conditions but can't use aggregate search conditions
question
The six clauses of the SELECT statement must be coded in the following order: SELECT, FROM, ORDER BY, WHERE, GROUP BY, HAVING SELECT, FROM, GROUP BY, HAVING, WHERE, ORDER BY SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
answer
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
question
When coding a query, you can add one or more summary rows to a result set that uses grouping and aggregates by coding the BLANK operator.
answer
WITH ROLLUP
question
Which of the statements below best describes the result set returned by this SELECT statement? SELECT vendor_id, SUM(invoice_total - payment_total - credit_total) AS column_2 FROM invoices WHERE invoice_total - payment_total - credit_total > 0 GROUP BY vendor_id The total amount invoiced by each vendor_id The unpaid balance for each invoice The total of paid invoices for each vendor_id The total unpaid balance due for each vendor_i
answer
The total unpaid balance due for each vendor_i
question
Which of the statements below best describes the result set returned by this SELECT statement? SELECT vendor_state, COUNT(*) AS column_2 FROM vendors GROUP BY vendor_state HAVING COUNT(*) > 1 The names of the vendors in each state The duplicate vendors from each state The number of vendors in each state The number of vendors in each state that has more than one vendor
answer
The number of vendors in each state that has more than one vendor
question
Write an aggregate expression for the number of unique values in the vendor_id column: BLANK
answer
COUNT(DISTINCT vendor_id)
question
Write an aggregate expression to calculate the average value of the invoice_total column, excluding null values: BLANK
answer
AVG(invoice_total)
question
Write an aggregate expression to find the oldest date in the invoice_date column: BLANK
answer
MIN(invoice_date)
question
Write an aggregate expression to find the vendor_name column that's last in alphabetical order: BLANK
answer
MAX(vendor_name)