1.Write a SeLECT statement that returns these columns;
The counts of the number of orders in the Orders table
The sum of the TaxAmount columns in the Ordeers table.
---------------------------------------------------------------------------
2.Write a SELECT statement that returns one row for each customer that has orders with these columns.
The EmailAddress column from the customer table.
The sum of the item price in the OrderItems table multiplied by the quantity in the OrderItems table
The sum of the discount amount column in the OrderItem table multipled by the quantity in the OrderItems Table
----------------------------------------------------------------------------------------------------------------------------------------------------
3.Write a SELECT statement that answers this question: Which customers have ordered more that one product? Return columns:
The email address from customers table
The count of distinct products d from the customer's orders
Regards

VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 10:51 AM EST
SELECT COUNT(*), SUM(TaxAmount) FROM Orders
SELECT C.EmailAddress, SUM(O.item_price * O.quantity), SUM(O.discount_amount * O.quantity) FROM customer C JOIN OrderItems O ON O.id = C.id GROUP BY C.EmailAddress
SELECT C.EmailAddress, COUNT(DISTINCT O.Product) AS d FROM customer C JOIN OrderItems O ON O.id = C.id WHERE COUNT(DISTINCT O.Product) > 1 GROUP BY C.EmailAddress
pradeep kumar72 reputationPosted Feb 13, 2014, 8:54 PM EST
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 13, 2014, 8:58 PM EST
I tried like this
3RD one little tricky ...
I believe 1st is perfect , 2nd one not sure but tend to be correct 3rd one 100% wrong
Just assume and try :)
Thank you
SUNIL GUTTARank #1,832 · 810 reputationPosted Feb 14, 2014, 7:48 AM EST