alexx876

Untitled

May 6th, 2021
1,473
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.  
  3. channel_id,
  4.  
  5. CAST(channel_name AS String) AS channel_name,
  6.  
  7. CAST(comments_about_channel AS String) AS comments_about_channel,
  8.  
  9. CAST(username AS String) AS username,
  10.  
  11. snapshot_datetime
  12.  
  13. FROM
  14.  
  15. (
  16.  
  17. SELECT
  18.  
  19. channel_id,
  20.  
  21. channel_name,
  22.  
  23. comments_about_channel,
  24.  
  25. username,
  26.  
  27. snapshot_datetime,
  28.  
  29. rank
  30.  
  31. FROM
  32.  
  33. (
  34.  
  35. SELECT
  36.  
  37. groupArray(channel_id) AS channel_ids,
  38.  
  39. groupArray(channel_name) AS channel_names,
  40.  
  41. groupArray(comments_about_channel) AS comments_about_channel,
  42.  
  43. groupArray(username) AS username,
  44.  
  45. groupArray(snapshot_datetime) AS snapshot_datetimes
  46.  
  47. FROM
  48.  
  49. (
  50.  
  51. SELECT
  52.  
  53. x.channel_id,
  54.  
  55. x.channel_name,
  56.  
  57. x.comments_about_channel,
  58.  
  59. x.username,
  60.  
  61. x.snapshot_datetime
  62.  
  63. FROM
  64.  
  65. adteam_backend.channels x
  66.  
  67. ORDER BY
  68.  
  69. x.channel_name ASC, x.snapshot_datetime DESC
  70.  
  71. )
  72.  
  73. ) array JOIN channel_ids AS channel_id,
  74.  
  75. channel_names AS channel_name,
  76.  
  77. comments_about_channel AS comments_about_channel,
  78.  
  79. username AS username,
  80.  
  81. snapshot_datetimes AS snapshot_datetime,
  82.  
  83. arrayEnumerateUniq(channel_names) AS rank
  84.  
  85. )
  86.  
  87. WHERE
  88.  
  89. rank = 1
  90.  
  91. AND
  92.  
  93. channel_id IN (1365043287)
  94.  
RAW Paste Data