SQL數據記錄如何錯位組合排序輸出?
select a1,b1 from t 結果SQL記錄如下:
10001,1000000001
10001,1000000002
10001,1000000003
10001,1000000004
10001,1000000005
10002,1000000006
10002,1000000007
10002,1000000008
10002,1000000009
10002,1000000010
10003,1000000011
10003,1000000012
10003,1000000013
10003,1000000014
10003,1000000015
如何排列成:
10001
1000000001
1000000002
1000000003
1000000004
1000000005
10002
1000000006
1000000007
1000000008
1000000009
1000000010
10003
1000000011
1000000012
1000000013
1000000014
1000000015
求高手指教?
select a from ((select distinct 第一列 as a, 第一列 as b, 0 as c from table)
union
(select distinct 第二列 as a, 第一列 as b, 1 as c from table))
orderby b
orderby a
orderby c