Microsoft SQL Count problem

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-08T19:01:15Z Indexed on 2010/04/08 19:03 UTC
Read the original article Hit count: 359

Filed under:
|
|

Hey smarties. I'm having trouble with the following SQL statement. I know that I can't do a GROUP BY on the OnlineStatus column, and it makes sense because it's a function call, not an actual column in my table. How would I modify this so that I can get a count of how many users are online?

SELECT  CASE dbo.fnGetWebUserOnlineStatus(W.Id) 
            WHEN 1 THEN 'Online' 
            WHEN 2 THEN 'Ingame' 
            ELSE 'Offline' 
        END AS OnlineStatus

        FROM dbo.WebUsers W

        WHERE W.[Status]=1

        GROUP BY OnlineStatus

© Stack Overflow or respective owner

Related posts about sql

Related posts about count