当前位置: 代码迷 >> Sql Server >> 查询数据库中某一列是否连续,该如何解决
  详细解决方案

查询数据库中某一列是否连续,该如何解决

热度:42   发布时间:2016-04-27 19:17:14.0
查询数据库中某一列是否连续
数据库中有一列是NO,怎么样查询它的值是否连续

------解决方案--------------------
SQL code
if exists(select 1 from tb a where no>(select min(no) from tb) and not exists(select 1 from tb where no=a.no-1))select '不连续'else'连续'
------解决方案--------------------
SQL code
if exists(select 1 from tb group by no having max(no)-min(no)+1=count(*))print '存在'
  相关解决方案