2015年1月30日 星期五

mssql 取區間號碼

參考來源
---
select id1,(select min(id)-1 from table where id > id1) as id2 from (
select id+1 as id1 from table where id+1 not in (select id from table) and id < (select max(id) from table)
) as t1

還真好用!! 取區間號碼