风言枫语  

题目如下:

Num

1
2
4
6
7
8
10
11
13

 

写条SQL语句转成下表:

Column1  Column2

1              2
4              4
6              8
10           11
13           13

 

 

答案:

selectMIN(Num),MAX(Num)from 

(selectROW_NUMBER()over (orderbyNum)rk,NumFromNumbers)A

Groupby (A.rk-A.Num)

orderbyMin(Num)

 

 

posted on 2013-10-12 22:34  风言枫语  阅读(268)  评论(0编辑  收藏  举报