读书人

很简单的有关问题

发布时间: 2012-03-02 14:40:29 作者: rapoo

很简单的问题求助
有一score列如下:
score
10
50
-20
-40

我如何用一个语句实现的查询结果如下:
score score2
10 -20
50 -40
也就是score里实现的是> 0的数显示出来,而score2实现的是 <0的数都显示出来!谢谢



[解决办法]
select id=identity(int1,1) , score into temp1 where score > 0
select id=identity(int1,1) , score into temp2 where score < 0

select temp1.score , temp2.score from temp1
full join temp2
on temp1.id = temp2.id

读书人网 >SQL Server

热点推荐