Go
Alter procedure SOW_proc
as
begin
declare @i int
set @i = 1
declare @j int
set @j = 1
While(@i <= 84)
Begin
select ' ' as 'SOW_Id', ' ' as 'SOW_description', ' ' as 'CostCenter',
' ' as 'CostCenter_description', ' ' as 'CostCenter_type', Profit,
Revenue, Expenses, ' ' as 'Currency'
from Fact_table where SOW_Id is null
union all
Select 'Total' + '-' + SOW_table.SOW_Id, SOW_table.SOW_description, ' ', ' ', ' ',
SOW_VW.Profit, SOW_VW.Revenue, SOW_VW.Expenses, SOW_VW.Currency
from SOW_TABLE, SOW_VW
where SOW_table.SOW_Id = SOW_VW.SOW_ID and SOW_TABLE.SOW_RowID = @i
while(@j = @i)
Begin
select ' ' as 'SOW_Id', ' ' as 'SOW_description', ' ' as 'CostCenter',
' ' as 'CostCenter_description', ' ' as 'CostCenter_type', Profit, Revenue,
Expenses, ' ' as 'Currency'
from Fact_table where SOW_Id is null
union all
Select SOW_TABLE.SOW_ID, SOW_TABLE.SOW_description, CostCenter_table.CostCenter,
CostCenter_table.CostCenter_desc, CostCenter_table.Project_type,
CostCenter_vw.Profit, CostCenter_vw.Revenue, CostCenter_vw.Expenses,
CostCenter_VW.Currency
from SOW_TABLE, CostCenter_table, CostCenter_vw, Fact_table
where SOW_TABLE.SOW_ID = FACT_TABLE.SOW_Id
and FACT_TABLE.CostCenter_id = CostCenter_table.CostCenter_Id
and CostCenter_table.CostCenter_id = CostCenter_vw.CostCenter_id
and SOW_TABLE.SOW_RowID = @j
set @j = @j + 1;
end
Set @i = @i + 1
end
end
当我运行上面的代码时,我得到了这个结果。由于积分不足,我无法上传图片。 我想要的是删除两行之间的所有标题,因为使用相同的标题。 我无法使用&#39; union all&#39; as&#39; union all&#39;不能与&#39;同时使用。 请建议一些方法来做到这一点。