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 |
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2008-03-17 : 05:07:35
|
Hi.I've wrote this query:SELECT TOP 10 COUNT(*) AS ItemsSold, ProductName, order_details_product_id, SUM(order_details_price) AS order_details_priceFROM tbl_Detail_Order_ProductWHERE (OrderStatus NOT IN (14, 15))GROUP BY order_details_product_id, ProductName, order_details_priceORDER BY ItemsSold DESCwhich works fine and have these results:Purchased Returned Sold Part Number $ 598.29 37 16684 $ 200.29 33 16654 $ 300.29 25 16184 ...my problem is I want to show the returned column wich is:WHERE (OrderStatus IN (14, 15))I dont know how can I do that.I tried to write another query but it didnt worked correctly.plz help me.thanks |
|
Abu-Dina
Posting Yak Master
206 Posts |
Posted - 2008-03-17 : 11:18:31
|
Use CASE statement to do a condtional SUM. |
 |
|
|
|
|