首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-01-29 
查询数据库中某一列是否连续数据库中有一列是NO,怎么样查询它的值是否连续[解决办法]SQL codeif exists(se

查询数据库中某一列是否连续
数据库中有一列是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 '存在' 

热点排行