Link to home
Create AccountLog in
Avatar of Chris Michalczuk
Chris MichalczukFlag for United Kingdom of Great Britain and Northern Ireland

asked on

sum values and count numbers of rows syntax sql

I want to return a result which gives the  Total Value  stored in the field Invoice_Value grouped by The field Toplevel for a specific date range. I'd also like a row count for the result

Result would be

Toplevel   TotalValue  No of rows
A               2000          10
B                1000          30

this doesnt work!!!

SELECT     SUM(SLAContract_InvoiceValue) AS Value, SlaContract_TopLevel
FROM         tblSLAContract
WHERE     (SLAContract_InvoiceDate >= CONVERT(datetime, '2008/02/01 00:00:00', 120)) AND (SLAContract_InvoiceDate <= CONVERT(datetime,
                      '2008/02/29 00:00:00', 120))
GROUP BY SLAContract_InvoiceValue, SlaContract_TopLevel
Avatar of jtbartels
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Forced accept.

EE Admin