sql 送分玩
tab
id
1
2
4
5
7
结果:
id
(3,6)
一条语句!嘿嘿!
[解决办法]
3,6怎么来的?
[解决办法]
我只接分,不答题,因为一条语句我答不出来
[解决办法]
3.6是跳号处理
[解决办法]
not in
[解决办法]
看看.
[解决办法]
再加個表
[解决办法]
select '(3,6) ' from tab;
[解决办法]
哈哈,开个玩笑.
[解决办法]
谢谢。我接分玩
[解决办法]
jf
[解决办法]
我也接分, :)
[解决办法]
select top 10 a=identity(int,1,1) into #test from sysobjects a,sysobjects b
declare @i int
select @i=max([id]) from dbo.tab
select test.a from #test as test left join dbo.tab on a=[id]
where a <=@i and [id] is null
[解决办法]
忘记drop table #test了
[解决办法]
lz的意思不明确,jf
[解决办法]
不懂,学习来了,帮顶吧,一条语句好象太难了,高人呢,来看看
你能给我一分就不错了,谢谢!
[解决办法]
Create table #tb (id int)
insert #tb(id)Values(1)
insert #tb(id)Values(2)
insert #tb(id)Values(4)
insert #tb(id)Values(5)
insert #tb(id)Values(7)
insert #tb(id)Values(9)
declare @str varchar(1000)
set @str= '( '
declare @int int
set @int=1
select @str=case when @int=id then @str else @str+convert(varchar,@int)+ ', ' end,
@int=@int+case when @int=id then 1 else 2 end
from #tb order by id
set @str=left(@str,len(@str)-1)+ ') '
print @str
drop table #tb
--执行结果
--(3,6,8)
[解决办法]
declare @tab table(id int)
insert into @tab select 1
insert into @tab select 2
insert into @tab select 4
insert into @tab select 5
insert into @tab select 7
select
case when (a.id+1)=min(b.id)-1 then rtrim(a.id+1) else rtrim(a.id+1)+ '- '+rtrim(min(b.id)-1) end as 断号区间
from
(select * from @tab m where not exists(select 1 from @tab where id=m.id+1)) a,
(select * from @tab m where not exists(select 1 from @tab where id=m.id-1)) b
where
a.id <b.id
group by
a.id
/*
断号区间
------------
3
6
*/
[解决办法]
declare @tab table(id int)
insert @tab select 1
union all select 2
union all select 4
union all select 5
union all select 7
select id=a.id+1 from @tab b join @tab a on b.id-1=a.id+1
where not exists(select 1 from @tab where id=b.id-1)
and
not exists(select 1 from @tab where id=a.id+1)
(5 行受影响)
id
-----------
3
6
(2 行受影响)
[解决办法]
declare @tab table(id int)
insert @tab select 1
union all select 2
union all select 4
union all select 5
union all select 7
select [间隔断号区]=rtrim(a.id)+ '—— '+rtrim(b.id)
from @tab b join @tab a on b.id-1=a.id+1
where not exists(select 1 from @tab where id=b.id-1)
and
not exists(select 1 from @tab where id=a.id+1)
间隔断号区
----------------------------
2——4
5——7
(2 行受影响)
[解决办法]
啥题啊~~,接分先
[解决办法]
up
[解决办法]
接分~
[解决办法]
print "id "
print "(3,6) "
哈哈
[解决办法]
not in (3,6)
[解决办法]
接分不错
[解决办法]
接分
[解决办法]
同上
[解决办法]
接分
[解决办法]
接阿
[解决办法]
System.out.println( "(3,6) ");
------------------------------
呼呼
[解决办法]
mark
[解决办法]
JF
[解决办法]
hao
[解决办法]
jf
[解决办法]
jf
[解决办法]
不懂,但UP
[解决办法]
jf
[解决办法]
顶