Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. declare @periodstart nvarchar(20) = '2020-01-24 00:00:00';
  2. declare @periodend nvarchar (20) = '2020-01-26 23:59:59';
  3.  
  4.  
  5. DECLARE @ClientVer nvarchar (20) = '0.0.105';
  6. Declare @Hours int = 24;
  7.  
  8. DECLARE @WorldID int = 1 ; -- 1, 2, 3, 4
  9.  
  10.  
  11. ;With Fails AS (
  12. select
  13. roomnumber AS RM,
  14. count(f.userid) AS 'Users'
  15.  
  16. from Users join finishrun as f on users.userid=f.userid
  17. where worldid = @WorldID
  18. and timestamp between f.created and dateadd(hh,@Hours,f.created)
  19. and users.created between @periodstart and @periodend
  20. and IsLeft = 0 and roomnumber!=0 and roomname!='-2'
  21. and registrationclientversion=@ClientVer
  22. and f.retention1d=1
  23.  
  24.  
  25. group by roomnumber
  26. )
  27.  
  28.  
  29. select roomnumber
  30. ,count(distinct(userid)) as 'Users'
  31. , count(userid) as 'Attempts'
  32. , min(Fails.[Users]) AS 'Fails'
  33. ,avg(healthpoints) as AvgHP
  34. ,avg(healing) as Heal
  35.  
  36. from runroominfo AS rri LEFT JOIN fails ON Fails.RM = rri.roomnumber
  37. where worldid = @WorldID
  38. and timestamp between created and dateadd(hh,@Hours,created)
  39. and created between @periodstart and @periodend
  40. and roomnumber!=0 and healthpoints<9999
  41.  
  42.  
  43. group by roomnumber
  44. order by roomnumber
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement