Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2010-05-11 : 08:53:55
|
Orders TableOrder_Day Prod_Id Customer_ID Qty_Sold1/5/2010 P1 C1 1010/5/2010 P2 C2 301/4/2010 P2 C1 2010/4/2010 P1 C2 401/3/2010 P2 C1 3010/3/2010 P1 C2 20Customer TableCustID City C1 ChennaiC2 Delhi a) Write a SQL query to get Total Quantity Sold by Month. The output should have two columns - Month and Total Quantity Sold.b) Write a SQL query to get Total Quantity Sold by City. The output should have two columns – City Name and Total Quantity Sold.c) Assuming the above Order tables have more than 100 distinct Prod_ids transaction, write a Sql to get Top 10 Distinct Product_ids by Quantity_sold. Don’t use any function, write the Sql to get the results. The output should have two columns Product_Id and Quantity_Sold.d) Get me all the products that were ordered by customer C1 on 10/4/2010 AND 10/3/2010. The result should include ONLY those products that were ordered by C1 on BOTH the days.Please help me the best answers for above questions.Thanks a Lot |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-11 : 08:55:50
|
| What have you tried so far?MadhivananFailing to plan is Planning to fail |
 |
|
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2010-05-11 : 09:00:00
|
| Hi MadhiI am trying But I expect best method from experts so for that i will learn what i have done wrong things..I hope you help meThanks a Lot |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-05-11 : 09:13:00
|
| Your questions sound like homework / test questions.At least make a stab at the questions and then you'll get feedback about what you are doing and why it's right or wrong.You won't learn anything if you don't try.A Hint to get you started.a) GROUP BY and SUM -- I leave extracting the MONTH portion of the date to youCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2010-05-11 : 10:20:45
|
quote: Originally posted by Transact Charlie Your questions sound like homework / test questions.
Ding, ding, ding - give the man a cigar! Finals time is upon us once again. I suspect there will be a lot of this for a while. As both Madhi and TC stated, what have YOU tried?Terry-- A word to the wise ain't necessary - it's the stupid ones that need the advice. -- Bill Cosby |
 |
|
|
|
|
|