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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Show Data only when Negative Value

Author  Topic 

jbrown7232
Starting Member

22 Posts

Posted - 2014-06-19 : 15:25:20
Hello and Thanks in Advance. I have the following query:

Select SKU_Number,SKU_Name,Sum(Invoice_Quantity)
as Number_of_Cases,Sum(Invoice_Quantity)/COUNT(orderinvoice)as Average_Cases,SUM(SKU_Price)
as Purchases,COUNT(orderinvoice)as order_count,
Store_Number,Customer_Name, Customer_Address,
Customer_City , Customer_State , Customer_Zip, Unitofmeasure as UOM,qtyshipped as PartialCase
from Sales4000 where CustCode = 'Target'
group by Store_Number, SKU_Name, SKU_Number,Customer_Name,
Customer_Address, Customer_City , Customer_State , Customer_Zip,Unitofmeasure, qtyshipped

I just want PartialCase column populated with the negative value only when there is a negative value otherwise just put a 0

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-19 : 15:35:09
PartialCase = CASE WHEN qtyshipped > 0 THEN 0 ELSE qtyshipped END

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jbrown7232
Starting Member

22 Posts

Posted - 2014-06-19 : 16:16:23
Tara ....wow you are smart....Will you marry me?

Thanks

quote:
Originally posted by tkizer

PartialCase = CASE WHEN qtyshipped > 0 THEN 0 ELSE qtyshipped END

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-19 : 16:37:07


Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -