--计算数值表 create table tmp (col1 int,col2 int,co3 int) go
declare @n int ,@col1 int,@col2 int,@col3 int set @n=0 while (@n<=504) begin select @col1=max(case when rn=1 then number end) ,@col2=max(case when rn=2 then number end) ,@col3=max(case when rn=3 then number end) from ( select number,rn=row_number() over(order by getdate()) from ( select top 3 number from master..spt_values where type='p' and number between 1 and 9 order by checksum(newid()) )k ) z select @col1,@col2,@col3 if(not exists(select * from tmp where col1=@col1 and col2 = @col2 and co3 =@col3)) begin set @n = @n+1; insert tmp select @col1,@col2,@col3; end end go select * from tmp drop table tmp
[最优解释]
select * from ( select left(rtrim(number),1) as col1, substring(rtrim(number),2,1) as col2,right(rtrim(number),1) as col3 from master..spt_values where type='p' and number between 123 and 987 ) X where convert(int,col1)*convert(int,col2)*convert(int,col3)>0 and col1<>col2 and col1<>col3 and col2<>col3
[其他解释] [code=SQL] declare @test table(n int) insert @test select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9
SELECT A.N,B.N,C.N FROM @test A,@test B,@test C WHERE A.N<>B.N AND B.N<>C.N AND A.N<>C.N
[其他解释] sssssssss [其他解释] 1111 [其他解释] 2222222
[其他解释] 不就从111到999, 然后把有重复的删掉。。。。 [其他解释]
.......好像是哦...... [其他解释]
一语惊醒梦中人 [其他解释] 拣个分 [其他解释]
沟沟 。。。 我难过了。。 居然陷入了漩涡。。 打击到我了。。。
我居然没想到 [其他解释]
为此 赔偿点可用分 当精神损失费吧
好么?沟哥~ [其他解释] 我日,你应该加分到300,以示惩戒 当然我不黑心的,给我200即可,剩下的大家平分 [其他解释] [code=SQL] declare @test table(n int) insert @test select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9
SELECT A.N,B.N,C.N FROM @test A,@test B,@test C WHERE A.N<>B.N AND B.N<>C.N AND A.N<>C.N