I have the following simple request:
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 selection list, but to impose certain conditions on them. Is this done using the CASE () statement in some way? I tried putting Where clauses inside a select list, and this does not seem to be allowed. I'm not sure that subqueries are needed here, but I don't think so.
For example, I need one function COUNT (), which takes into account only problems in a certain range, then another in a different range or in different different 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 login.
Thank.
source
share