Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Decompose the following SELECT statement to show the intermediate table before grouping. Your answer should contain a SELECT statement without the GROUP BY clause. You

Decompose the following SELECT statement to show the intermediate table before grouping. Your answer should contain a SELECT statement without the GROUP BY clause. You should be able to compute the aggregate functions using the intermediate generated by your SELECT statement answer.

SELECT Customer.CustNo, CustFirstName, CustLastName, SUM(Qty) AS ProdQty, 

SUM(Qty*ProdPrice) AS TotOrdAmt

FROM OrderTbl, OrdLine, Product, Customer

WHERE OrdDate BETWEEN '1-Jan-2021' AND '31-Jan-2021'

AND OrderTbl.OrdNo = OrdLine.OrdNo

AND OrdLine.ProdNo = Product.ProdNo

AND Customer.CustNo = OrderTbl.CustNo

AND (ProdName LIKE '%Ink Jet%'

OR ProdName LIKE '%Laser%')

GROUP BY Customer.CustNo, CustFirstName, CustLastName

HAVING SUM(Qty) > 2;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The code of SQL is as follow WITH IntermediateTable AS SELECT Custo... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Gail Fayerman

1st Canadian Edition

9781118774113, 1118774116, 111803791X, 978-1118037911

More Books

Students also viewed these Databases questions

Question

-

Answered: 1 week ago