--执行这句,应该就比较明白
select   Field1=ID
,Field2=case ID%2 when 0 then name else '' end
,Field3=ID
,Field4=case ID%2 when 1 then name else '' end
,列号=ID%2
,组号=ID/2
from [aaa]

解决方案 »

  1.   

    在查詢分析器中 CTRL+L ,看看執行計劃
      

  2.   

    zjcxc(: 邹建 :) 的答案为什么能实现,我怎么没看懂,能帮忙解释一下吗
      

  3.   

    得到的是这个结果!
    1 1 a 1 0
    2 b 2 0 1
    3 3 c 1 1
    4 d 4 0 2
    5 5 e 1 2
    6 f 6 0 3
      

  4.   

    这样可以得到结果
    select   Field1=min(ID)
    ,Field2=max(case ID%2 when 1 then name else '' end)
    ,Field3=max(ID)
    ,Field4=max(case ID%2 when 0 then name else '' end)
    from tabled
    group by (ID+1)/2