I have the following simple query,
SELECT US_LOGON_NAME as Username,
COUNT(I.IS_ISSUE_NO) as Issues
FROM ISSUES I JOIN USERS U ON I.IS_ASSIGNED_USER_ID = U.US_USER_ID
WHERE I.IS_RECEIVED_DATETIME BETWEEN 20110101000000 AND 20110107000000
GROUP BY U.US_LOGON_NAME;
Where I want to add additional COUNT() functions to the select list but impose certain where conditions on them. Is this done with a CASE() statement somehow? I tried putting Where clauses inside the select list, and that doesn't seem to be allowed. I'm not sure if subqueries are really necessary here, but I dont think so.
For example I want one COUNT() function that only counts issues within a certain range, then another in another range or with other assorted conditions, etc:
SELECT US_LOGON_NAME as Username,
COUNT(I.IS_ISSUE_NO (condition here)
COUNT(I.IS_ISSUE_NO (a different condition here)
etc...
Still grouped by Logon Name.
Thanks.