Guest User

Untitled

a guest
Mar 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. select d.id, d.value, d.device
  2. from (
  3. select
  4. id, value, device,
  5. count(*) over (partition by device) records_in_group,
  6. row_number() over (partition by device order by id) row_number
  7. from data
  8. ) d
  9. inner join (
  10. select
  11. d.device,
  12. row_number() over (partition by d.device order by id) idx
  13. from data d
  14. ) n on n.device = d.device and row_number = floor(n.idx * records_in_group / 3)
  15. order by d.device, d.id;
Add Comment
Please, Sign In to add comment