Guest User

Untitled

a guest
Aug 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. select
  2. u.id as UserID,
  3. u.DisplayName,
  4. u.Username,
  5. u.Capacity as Capacity,
  6. count(cq.chatid) as ActiveChats,
  7. case when count(cq.chatid) >= u.Capacity then 1 else 0 end as AtCapacity
  8. from
  9. users u
  10. left join
  11. ChatQueueItems cq
  12. on
  13. cq.UserID = u.ID
  14. left join
  15. Chats c
  16. on
  17. c.ID = cq.ChatID
  18. and
  19. c.[Status] in (0,1) -- 0 = awaiting pickup, 1 = active
  20. where
  21. u.[online] = 1
  22. group by
  23. u.id,
  24. u.DisplayName,
  25. u.Username,
  26. u.capacity
Add Comment
Please, Sign In to add comment