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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-07-15 : 07:43:19
|
Dave writes "Hi, I am after some help on trying to find out the quantity of products sold in a given week, month and year. I can do this as a seperate query/stored procedure, but I want these to be displayed in one table as shown below:Product | In Stock | Qty Week | Qty Month | Qty YearThe current stored procedure looks something like this:CREATE Procedure OMNI_Product_Top20ASSELECT TOP 20 OMNI_OrderDetails.ProductID, SUM(OMNI_OrderDetails.Quantity) as TotalNum, OMNI_ProductList.Manufacturer, OMNI_ProductList.Model, OMNI_ProductCategory.ShortName, COUNT(*) as InStock FROM ( ( OMNI_ProductCategory INNER JOIN OMNI_ProductList ON OMNI_ProductCategory.CategoryID = OMNI_ProductList.CategoryID ) INNER JOIN OMNI_OrderDetails ON OMNI_ProductList.ProductID = OMNI_OrderDetails.ProductID) INNER JOIN OMNI_StockList ON OMNI_ProductList.ProductID = OMNI_StockList.ProductIDGROUP BY OMNI_OrderDetails.ProductID, OMNI_ProductList.Manufacturer, OMNI_ProductList.Model, OMNI_ProductCategory.ShortName ORDER BY TotalNum DESC-----TotalNum currently gives me the total number of products in stock.I have tried to use Access2003 to try to help create the query unfortunately I can't re-create it as there are multiple counts happening, and this seems to be a bit beyond me.Any Help would be really appreciated, I am using SQL Server 7.0Thank in advanceDave" |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-15 : 08:40:41
|
Does your query work?quote: I am after some help on trying to find out the quantity of products sold in a given week, month and year.
Posting the DDL will be helpfulMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|