Guest User

Untitled

a guest
Jan 23rd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. -- 1) ran fine for 2 mi records table.
  2. -- 2) assuming the table name is clients.
  3.  
  4. select did, cid, did - cid as gap
  5. from
  6. (
  7. select
  8. d.id as did,
  9. (select min(id) as cid from clients c where c.id > d.id ) as cid
  10. from
  11. clients d
  12. ) as t
  13. order by gap asc
  14. limit 10
Add Comment
Please, Sign In to add comment