Question: For Queries 1-6 1. What each query is requesting from the database. 2. Include descriptions for what ALL of the following SQL keywords are doing
For Queries 1-6
1. What each query is requesting from the database.
2. Include descriptions for what ALL of the following SQL keywords are doing in each query they are present in: SELECT, FROM, JOIN, WHERE, and ORDER BY
3. Include a description of what is being aggregated and how, including the aggregate functions, the GROUP BY clause, and the HAVING clause.
QUERY 1
SELECT COUNT (*) AS number_of invoices,
SUM (invoice_total payment_total credit_total) AS total_due
FROM invoices
WHERE invoice_total payment credit_total > 0
QUERY 2
SELECT `After 1/1/2014` AS selection _date,
COUNT (*) AS number_of _invoices
ROUND (AVG (invoice_total), 2) AS avg_invoice_amt,
SUM (invice_total) AS total_invoice_amt
FROM invoices
WHERE invoice_date > `2014 -01-01`
QUERY 3
SELECT `After 1/1/2014` AS selection _date,
COUNT (*) AS number_of _invoices
MAX (invoice_total) AS highest_invoice-total,
MIN (invoice_total) AS lowest_invoice_total
FROM invoices
WHERE invoice_date > `2014-01-01`
QUERY 4
SELECT MIN (vendor_name) AS first_vendor
MAX (vendor_name) AS last_vendor
COUNT (vendor_name) AS number_of_vendors
FROM vendors
QUERY 5
SELECT COUNT (DISTINCT vendor_id) AS number _of _vendors,
COUNT (vendor_id) AS number_of_invoices,
ROUND (AVG (invoice_total), 2) AS avg_invoice_amt,
SUM (invoice_total) AS total_invoice_amt
FROM invoices
WHERE invoice_date > `2014-01-01`
QUERY 6
SELECT vendor_id, ROUND (AVG (invoice_total), 2) AS average_invoice_amount
FROM invoices
GROUP BY vendor_id
HAVING AVG (invoice__total) > 2000
ORDER BY average_invoice_amount DESC
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
