我的存储过程如下: -
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_crystal_project_order_dtf_dttax]
@id int
AS BEGIN
SELECT
tbltax.taxname, ROUND(tbltax.taxamount,2) AS 'taxamount'
FROM
(SELECT
'Sub Total:' as 'taxname',
sub_total1_factory as 'taxamount',
-10 as 'OrderCol'
FROM
project_order_rewise
WHERE
project_order_rewise.[id] = @id
UNION
SELECT
'Less Discount @ ' + cast(isnull([discount], 0) AS varchar(max)) + '%:' as 'taxname',
(sub_total1_factory * isnull([discount], 0) / 100) AS 'taxamount',
-9
FROM
[dbo].project_order_rewise
WHERE
[dbo].project_order_rewise.[id] = @id
UNION
SELECT
'Packaging / Forwarding:' as 'taxname',
transportation_charges_factory as 'taxamount',
-8
FROM
project_order_rewise
WHERE
project_order_rewise.[id] = @id
UNION
select 'Sub Total:' as 'taxname'
,sub_total2_factory as 'taxamount'
,-7
from [dbo].project_order_rewise
where [dbo].project_order_rewise.[id]=@id
union
select 'Add '+[tax_master].[tax_name]+ ' @ '+cast([tax_value].[value]as varchar(max))+'%:' as 'taxname'
,project_order_tax.[amt_factory] as 'taxamount'
,-6
from project_order_rewise inner join (tax_master inner join (project_order_tax inner join tax_value
on project_order_tax.tax_value = tax_value.id)
on tax_master.id=tax_value.tax_id)
on project_order_rewise.id=project_order_tax.pro_order_rewise_id
where project_order_rewise.id=@id
union
select 'Sub Total:' as 'taxname'
,sub_total3_factory as 'taxamount'
,-5
from project_order_rewise
where project_order_rewise.[id]=@id
union
select 'Transportation Charges:' as 'taxname'
,newtransportchrg as 'taxamount'
,-4
from project_order_rewise
where project_order_rewise.[id]=@id
union
select 'Sub Total:' as 'taxname'
,subtotalwithtrans as 'taxamount'
,-3
from project_order_rewise
where project_order_rewise.[id]=@id
union
select 'Add '+[tax_master].[tax_name]+ ' @ '+cast([tax_value].[value]as varchar(max))+'%:' as 'taxname'
,project_order_tax1.[amount] as 'taxamount'
,-2
from project_order_rewise inner join (tax_master inner join (project_order_tax1 inner join tax_value
on project_order_tax1.tax_value = tax_value.id)
on tax_master.id=tax_value.tax_id)
on project_order_rewise.id=project_order_tax1.pro_order_rewise_id
where project_order_rewise.id=@id
union
select 'Grand Total:' as 'taxname'
,grandtotal1 as 'taxamount'
,-1
from project_order_rewise
where project_order_rewise.[id]=@id
) as tbltax
order by OrderCol
end
exec sp_crystal_project_order_dtf_dttax 60
它返回此输出:
taxname taxamount
---------------------------------------
Sub Total: 220
Less Discount @ 0.00%: 0
Packaging / Forwarding: 0
Sub Total: 220
Add Excise Duty @ 12.36%: 27.19
Sub Total: 247.19
Transportation Charges: 0
Sub Total: 247.19
Grand Total: 247.19
我已经以这种方式实现了我的程序,因为我想在一个中显示它 水晶报告。我不想要选择条款的结果,其中包括税收,折扣,包装/转发,税收,运输费用是0.我不想显示结果。当我使用where子句
时where taxamount <> 0 or taxamount <> null
结果显示如下:
taxname taxamount
---------------------------------------
Sub Total: 220
Add Excise Duty @ 12.36%: 27.19
Grand Total: 247.19
当我在谷歌浏览器中执行页面时。在Crystal Reports中,结果显示如下:
taxname taxamount
--------------------------------------
Sub Total: 220
Sub Total: 220
Sub Total: 220
Sub Total: 220
Add Excise Duty @ 12.36%: 27.19
Sub Total: 247.19
Sub Total: 247.19
Sub Total: 247.19
Grand Total: 247.19
有人可以告诉我解决方法。