Queries.docx
Queries.docx
4) Find out the Max, Min, Count, Sum, Average Sales for each Ship Mode
Select [Customer ID], count([Order ID]) as CO from Orders group by [Customer ID]
having count([Order ID])>30 order by CO desc
8) How good West region is as compared to East region with respect to total sales (Multiple)?
Select
(Select sum(sales) as TS from orders where Region='West')
/
(Select sum(sales) as TS from orders where Region='East') as W_Vs_E
9) Correlated Sub-Query
create table Details(
Product_id varchar(255),
Product_name varchar(255),
category varchar(255),
List_price int)
-- Finds the products whose list price is equal to the highest list price of the
products within the same category
SELECT
product_name,
list_price,
category
FROM
Details d1
WHERE
list_price IN (
SELECT
MAX (d2.list_price)
FROM
Details d2
WHERE
d2.category = d1.category
GROUP BY
d2.category
)
ORDER BY
Category, product_name;