UserData table (UserID, Sales, Credits)
I need to return the SUM of sales, the amount of credits and the number of rows returned for a given date range.
Is this possible in 1 request?
SELECT COUNT(*), SUM(Sales), SUM(Credits) FROM UserData WHERE TransactionDate BETWEEN @StartDate AND @EndDate
You can also provide names for computed columns such as
SELECT COUNT(*) AS NumRows, SUM(Sales) AS SalesTotal, SUM(Credits) AS CreditsTotal FROM UserData WHERE TransactionDate BETWEEN @StartDate AND @EndDate