SQLTeam.com | Weblogs | Forums

Querying denormalised tables

sql2008r2
tsql
sql2012
sql2014
sql2008

#1

I am a newbie in sql. recently i came across a set of questions specific to query a denormalised table. Can someone help me how to answer these questions

Customer_id Order_id Order_line_id Product_type Order_Date
C1000 O1000 L100 Textbook 1/1/2016
C1000 O1000 L101 Ebook 1/1/2016
C1000 O1000 L102 Texbook 1/1/2016
C1000 O1001 L103 Subscription 1/2/2016
C1001 O1002 L104 Ebook 1/2/2016
C1001 O1002 L105 Ebook 1/2/2016
C1002 O1003 L106 Textbook 1/3/2016
C1002 O1003 L107 Textbook 1/3/2016

• I would like to find out total customer who ordered the products in Jan 2016

• I would like to know number of customers who placed more than one order in Jan 2016

• I would like to find out number of orders that have Ebook as well as Textbook ordered together as a part of same order

• I would like to find out number of new customers who purchased the product for the first time in Jan