SQL Scenarios
SQL Scenarios
SQL Scenarios
19)RESELLER SALES
--display country,state,store,sales2003 and sales2004
20)-- ABOVE QUERY USING CASE STATEMENT
21)--For the year 2003 display the INDIVIDUAL custname,salesamount ,phone,email,
aboveavg(Y/N)
--PER ORDER
22)--sum(case when year(ssoh.orderdate)=2003 then ssoh.totaldue else 0 end)as
saleamount2003,
23)--For the year 2003 display the INDIVIDUAL custname,salesamount ,phone,email,
aboveavg(Y/N)
--PER CUSTOMER
24)--sum(case when year(ssoh.orderdate)=2003 then ssoh.totaldue else 0 end)as
saleamount2003,
25)
--display salespersonname,ytdsale,mtdsale,pyytdsale,pymtdsale
26)--2003,individual customers
--display country,newcustomerscount,oldcustomerscount,totalcustomerscount
27)--sum(case when a.customerid is null then 1 else 0 end)+sum(case when
a.customerid is not null then 1 else 0 end ) as total
28)--search INDIVIDUAL CUSTOMERS when the below parameters are entered...(searching
for customers starting with...)
--display firstname,lastname,city,state,country
29)--INDIVIDUAL SALES
--display productid,productname,rank2003,rank2004 (use the below rank function)
30)--for the above scenario partition within the category name display the top 2
ranks for 2003
31)--display top 5 rows for 'CUSTOMERTYPE='S' (top 5 store customers) , 'I'
(top 5 individual customers) (TOTAL 10 ROWS)
--CUSTID,CUSTNAME,SALEAMOUNT,RANK
32)
--ALL COUNTRIES
--ONLY INDIVIDUAL CUSTOMER
--display count for custadded2003,custlost2003,custadded2004,custlost2004
33)--below2003 customers
34)--in2003 customers
35)--below2004 customers
36)--in2004 customers
37)ASSIGNMENT
--to get the correct logic we have to get a table which is derived from the below
query
(--get studentid,maths,physics,chemistry,total)
-----------------------------------------------
--MAIN QUERY
42)--assignment
--write a function that returns table when provided names
--ex: getvaluetable('raja,king')
--output: nocolumnname
-- raja
-- king
44)--assignment
--individual customers
--create function getcustomers(pageno,recordsperpage)
--which fetches custid,name,phone,email