SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Qty times total in query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taunt
Posting Yak Master

116 Posts

Posted - 03/20/2013 :  15:53:05  Show Profile  Reply with Quote
Hello here's my query:


SELECT  SalesH.SKU, SalesH.UPC, SalesH.Artist, SalesH.ItemName, SUM(SalesH.Quantity) AS Totalsold, Items.StockQty, SalesH.Attribute2 As format, SalesH.ReleaseDate,  SalesH.Cost*Totalsold as Totalmade
FROM    SalesH inner join Items on SalesH.ItemID = Items.ItemID
WHERE  (SalesH.ReleaseDate = '03/12/2013') AND (SalesH.TDTypeID = 1) AND (SalesH.TID = 1)
GROUP BY SalesH.upc,SalesH.SKU, SalesH.Artist, SalesH.ItemName, SalesH.Attribute2, SalesH.ReleaseDate, Items.StockQty, SalesH.Cost, Totalsold
ORDER BY SalesH.Artist


What I'm trying to do is have sql give me the cost times totalsold (which is SUM(SalesH.Quantity)). So how would I go about wording that so sql understands. Right now it brings up the Totalmade column as null.

Thanks

chadmat
The Chadinator

USA
1974 Posts

Posted - 03/20/2013 :  16:01:19  Show Profile  Visit chadmat's Homepage  Reply with Quote
Are there rows that have NULL value for Quantity? If so, put ISNULL(Quantity,0)

-Chad
Go to Top of Page

taunt
Posting Yak Master

116 Posts

Posted - 03/20/2013 :  16:01:28  Show Profile  Reply with Quote
Arg! nevermind I got it to work using SalesH.Cost*SUM(SalesH.Quantity)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000