Question: For Queries 7-13 1. What each query is requesting from the database. 2. Include descriptions for what ALL of the following SQL keywords are doing
For Queries 7-13
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 7
SELECT vendor_id, COUNT (*) AS invoice_qty,
FROM invoices
GROUP BY vendor_id
QUERY 8
SELECT vendor_state, vendor_city,
COUNT (*) AS invoice_qty,
ROUND (AVG (invoice_total), 2) AS invoice_avg
FROM invoices JOIN vendors
ON invoices.vendor_id = vendors.vendor_id
GROUP BY vendor_stated, vendor_city
QUERY 9
SELECT vendor_state, vendor_city,
COUNT (*) AS invoice_qty,
ROUND (AVG (invoice_total), 2) AS invoice_avg
FROM invoices JOIN vendors
ON invoices.vendor_id = vendors.vendor_id
GROUP BY vendor_stated, vendor_city
HAVING COUNT (*) >= 2
QUERY 10
SELECT vendor_state, vendor_city,
COUNT (*) AS invoice_qty,
ROUND (AVG (invoice_total), 2) AS invoice_avg
FROM invoices JOIN vendors
ON invoices.vendor_id = vendors.vendor_id
GROUP BY vendor_state, vendor_city
HAVING AVG (invoice_total) > 500
ORDER BY invoice_qty DESC
QUERY 11
SELECT vendor_state, vendor_city,
COUNT (*) AS invoice_qty,
ROUND (AVG (invoice_total), 2) AS invoice_avg
FROM invoices JOIN vendors
ON invoices.vendor_id = vendors.vendor_id
WHERE invoice_total > 500
GROUP BY vendor_name
ORDER BY invoice_qty DESC
QUERY 12
SELECT
Invoice date,
COUNT (*) AS invoice_qty,
SUM (invoice_total) AS invoice_sum
FROM invoices
GROUP BY vendor_date
HAVING invoice_date BETWEEN `2014-05-01` AND `2014-05-31`
AND COUNT (*) > 1
AND SUM (invoice_total) >100
ORDER BY invoice_date DESC
QUERY 13
SELECT
Invoice date,
COUNT (*) AS invoice_qty,
SUM (invoice_total) AS invoice_sum
FROM invoices
WHERE invoice_date BETWEEN `2014-05-01` AND `2014-05-31`
GROUP BY invoice_date
HAVING COUNT (*) > 1
AND SUM (invoice_total) >100
ORDER BY invoice_date DESC
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
