Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1) ran fine for 2 mi records table.
- -- 2) assuming the table name is clients.
- select did, cid, did - cid as gap
- from
- (
- select
- d.id as did,
- (select min(id) as cid from clients c where c.id > d.id ) as cid
- from
- clients d
- ) as t
- order by gap asc
- limit 10
Add Comment
Please, Sign In to add comment