MSSQL Query With SUM Function To Include Other Fields
Posted on 2013-01-10
I have a Table in MSSQL...call it "CustomerPurchases", that has the following fields:
I need to summarize the data...BUT...I *ALSO* need to display...the "other" (non-summarized) fields in the query's output.
I created a query like the following:
Select CustomerNumber, sum(ProductSales), sum(ServiceSales)
group by CustomerNumber
That works, certainly, but I need to display:
...on the SAME OUTPUT.
When I attempt to add those (3) other fields, I get that "...is invalid in the select list because it is not contained in either an aggregate function..." error. What is the correct syntax/method to use here?
Please help!...much appreciated!...Mark