這看起來像瘋了一個解決方案,但可以使用窗口函數ROW_NUMBER()
和使用CASE
表達檢查,如果行數大於1,像實現它:
select
[Vch No.],
[Vch Type],
case when rn > 1 then '' else [Vch Ref] end as [Vch Ref],
case when rn > 1 then '' else [Date] end as [Date],
case when rn > 1 then '' else [Party Name] end as [Party Name],
case when rn > 1 then '' else [Sales Ledger] end as [Sales Ledger],
case when rn > 1 then '' else [Amt] end as [Amt],
[GST Ledger],
[TaxAmount],
case when rn > 1 then '' else [Total] end as [Total]
from (
select
[Vch No.],
[Vch Type],
[Vch Ref],
[Date],
[Party Name],
[Sales Ledger],
[Amt],
[GST Ledger],
[TaxAmount],
[Total],
row_number() over (partition by [Vch No.],[Vch Type],[Vch Ref],[Date],[Party Name],[Sales Ledger],[Amt],[GST Ledger],[TaxAmount],[Total] order by [Vch No.]) rn
from [AccountData]
)x
看看數據類型,如果有Amt
是INT你應該將其轉換爲字符串,如果你想獲得空白值。
您應該在應用程序層而不是數據庫中執行此操作。 –
我正在將數據導出爲excel,並且沒有應用程序層。 –
他們不是真正重複的行,因爲GST分類賬是不同的,並且您想要顯示那 –