August 29, 2010 at 8:49 pm
I have a dataset like:
InvoiceNumber InvoiceDate PieceSalePrice
123456 10/10/2009 2500.00
123456 10/10/2009 3600.00
How do I query it so the results look like:
InvoiceNumber InvoiceDate InvoiceTotal
123456 10/10/2009 6100.00
This means to sum the PieceSalePrice on all InvoiceNumber with same InvoiceDate
Tried several things but no go
Any help would be appreciated
Thanks
Tom
August 29, 2010 at 8:59 pm
Dint SUM and GROUP BY help ?
Like ?
selelct invoicenumber, invoicedate, sum(invoice) invoicetotal
from table
group by invoicenumber, invoicedate
August 29, 2010 at 9:50 pm
That worked, I swear I tried it but I was wrong in the order at the group clause, I was grouping by the PieceSalePrice first instead of the InvoiceNumber.
This is my error:
Select
InvoiceNumber,
DateSale,
Sum(ArtPiecePrice) As InvoiceTotal
from Invoices
Where InvoiceNumber = '0173'
Group By ArtPiecePrice,InvoiceNumber,DateSale
Thanks a lot
Tom
August 29, 2010 at 10:20 pm
jcharrasqueado (8/29/2010)
That worked, I swear I tried it
It happens, Tom.. More than the order at the GROUP BY clause, you perhaps needed some more coffee 😀
August 30, 2010 at 9:40 pm
ColdCoffee (8/29/2010)
jcharrasqueado (8/29/2010)
That worked, I swear I tried itIt happens, Tom.. More than the order at the GROUP BY clause, you perhaps needed some more coffee 😀
Or maybe less coffee :), thanks again, it worked like a charm.
Tom
August 31, 2010 at 7:29 am
Tom, it actually sounds like you really needed some Cold Coffee :w00t:
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
August 31, 2010 at 7:42 am
WayneS (8/31/2010)
Tom, it actually sounds like you really needed some Cold Coffee :w00t:
LOL.. Yeah Wayne! :w00t: :hehe:
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply