Counting rows | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Counting rows

I’m trying to display a value for 0.
Aplication in question is Dashboard call tracking software. When I run: SELECT count(cu.id) Chats_Holding, cu.queue, max(DateDiff(s, cu.created_date, GETDATE())) waitTime FROM sprt_chat_users cu, sprt_chat_users_info cui WHERE cu.last_modified > DateAdd(s, -90, GetDate()) AND (cu.status = ‘waiting’ or cu.status= ‘escalate’) AND cu.user_type=’user’ AND cui.user_name = cu.user_name AND cui.room = cu.room AND cu.queue like ‘%hotel%’ GROUP BY cu.queue In SQL, it returns 0, which it should return 0 because nothing is returned; But within Dashboard it is returning what seems to be a null value because nothing is displayed. Is there a way to have 0 reflected as a null value if the value is 0? The results have to appear in a form so I’d like some value listed if 0 is the value.

Weird requirement, but … SELECT CASE WHEN count(cu.id) = 0 THEN NULL ELSE count(cu.id) END Chats_Holding,
………………………………….
]]>