我找到了一種方法來做到這一點。兩個query
兩個table
然後Union All
那些result
。檢查下面的SQL:
Select [No Urut(L1)],[No Tampil (L1)],[Text Faktor (L1)],[No Urut(L2)],[No Tampil (L2)],[Text Faktor (L2)] From
(
Select IDAPK As ID,1 As SL,[No Urut(L1)],[No Tampil (L1)],[Text Faktor (L1)],'' As [No Urut(L2)],'' As [No Tampil (L2)], '' As [Text Faktor (L2)] From TableA
Union All
Select IDAFK As ID,2 As SL,'' As [No Urut(L1)],'' As [No Tampil (L1)],'' As [Text Faktor (L1)],[No Urut(L2)],[No Tampil (L2)],[Text Faktor (L2)] From TableB
) As TableAB Order By ID, SL
輸出的SQL:
您想要的格式類型可能在您的表示層最好處理。您是否期望使用原始查詢來生成該輸出,或者您是否使用其他語言? –
我正在使用SQL Server查詢... –
您使用的是什麼報告工具?或者你只是出口到CSV或其他東西?你到目前爲止試過什麼樣的查詢?爲什麼需要以這種方式呈現 - 是否適合最終用戶? –