在结果集中插入空白行

时间:2019-05-14 05:37:07

标签: sql sql-server tsql

我有一个查询,该查询返回一个具有输入行和主参考表中对应的重复行以及密集列的结果集的结果集,现在我需要在每组输入行及其重复项之后引入一个空白行。 任何人都可以帮助查询可能的查询语法或可以构建的任何功能吗? 下面是查询

Select A.* 
,CASE
When (A.[Reference] = B.[Reference] and A.[Amount in doc# curr#]= B.[Amount in doc# curr#]) then 'DUPEPAYA'
END  As [Status]
,CAST(Null as nvarchar(5)) As [RANK]
from MasterData A
Join InputData B on (A.[Reference] = B.[Reference] and A.[Amount in doc# curr#]= B.[Amount in doc# curr#])

Union All

Select distinct A.* 
,CASE
When (A.[Reference] = B.[Reference] and A.[Amount in doc# curr#]= B.[Amount in doc# curr#]) then 'DUPEPAYA'
END  As [Status]
,DENSE_Rank () Over (order by A.[Reference], A.[Account Description], A.dumptype asc) As [Rank]
from InputData A
Join MasterData B on (A.[Reference] = B.[Reference] and A.[Amount in doc# curr#]= B.[Amount in doc# curr#])

order by A.[Reference], A.[Account Description], A.dumptype asc

使用SQL

0 个答案:

没有答案