請問,怎樣對能夠對兩批資料 A ,B (A 是奇數群, B 系偶數群)進行排序,達到一行 A 一行B的效果呢,謝謝!
uj5u.com熱心網友回復:
--測驗資料
if not object_id(N'Tempdb..#A') is null
drop table #A
Go
Create table #A([num] int)
Insert #A
select 1 union all
select 3 union all
select 5 union all
select 7
GO
if not object_id(N'Tempdb..#B') is null
drop table #B
Go
Create table #B([num] int)
Insert #B
select 2 union all
select 4 union all
select 6 union all
select 8
Go
--測驗資料結束
SELECT t.num FROM (
Select *,ROW_NUMBER()OVER(ORDER BY num)rn from #A
UNION
Select *,ROW_NUMBER()OVER(ORDER BY num) from #B
)t ORDER BY rn
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/12933.html
標籤:疑難問題
