Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please modify the following query to reflect the data only from Qtr. #2 of the s

ID: 3566408 • Letter: P

Question

Please modify the following query to reflect the data only from Qtr. #2 of the standard year (Jan-Mar.).

SELECT Extract(YEAR from orderdate) as year,
Extract(MONTH from orderdate) as month,
COUNT(*) as numorders, COUNT(DISTINCT customerid) as numcust,
SUM(totalprice) as totspend,
SUM(totalprice)*1.0/COUNT(*) as avgordersize,
SUM(totalprice)*1.0/COUNT(DISTINCT customerid) as avgcustorder
FROM dw.orders o
WHERE Extract(MONTH from orderdate) > 9
GROUP BY Extract(YEAR from orderdate),
Extract(MONTH from orderdate)
ORDER BY 1, 2;

*************************************************************

The answer to the query is listed below, however, it does not work. The query does not work. error message: "SQL command not properly ended". Please check it again.

SELECT Extract(YEAR from orderdate) as year,
Extract(MONTH from orderdate) as month,
COUNT(*) as numorders, COUNT(DISTINCT customerid) as numcust,
SUM(totalprice) as totspend,
SUM(totalprice)*1.0/COUNT(*) as avgordersize,
SUM(totalprice)*1.0/COUNT(DISTINCT customerid) as avgcustorder
FROM dw.orders o
WHERE Extract(MONTH from orderdate) >=4 , Extract(MONTH from orderdate) <=6
GROUP BY Extract(YEAR from orderdate),
Extract(MONTH from orderdate)
ORDER BY 1, 2;

Explanation / Answer

SELECT Extract(YEAR from orderdate) as year,
Extract(MONTH from orderdate) as month,
COUNT(*) as numorders, COUNT(DISTINCT customerid) as numcust,
SUM(totalprice) as totspend,
SUM(totalprice)*1.0/COUNT(*) as avgordersize,
SUM(totalprice)*1.0/COUNT(DISTINCT customerid) as avgcustorder
FROM dw.orders o
WHERE Extract(MONTH from orderdate) > 9
GROUP BY Extract(YEAR from orderdate),
Extract(MONTH from orderdate)
ORDER BY 1, 2;

----------------------------------------------------------------------------------------------------------------------------------------

SELECT Extract(YEAR from orderdate) as year,
Extract(MONTH from orderdate) as month,
COUNT(*) as numorders, COUNT(DISTINCT customerid) as numcust,
SUM(totalprice) as totspend,
SUM(totalprice)*1.0/COUNT(*) as avgordersize,
SUM(totalprice)*1.0/COUNT(DISTINCT customerid) as avgcustorder
FROM dw.orders o
WHERE Extract(MONTH from orderdate) >=4 AND Extract(MONTH from orderdate) <=6
GROUP BY Extract(YEAR from orderdate),
Extract(MONTH from orderdate)
ORDER BY 1, 2;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote