Crystal report中的用例,相当于SQL查询
如何在Crystal Report查询中使用案例Crystal report中的用例,相当于SQL查询,sql,crystal-reports,Sql,Crystal Reports,如何在Crystal Report查询中使用案例 select StoreID, Sum(case when Year(Time)=2016 then ExtendedCost end) [Cost(2016)], Sum(case when Year(Time)=2017 then ExtendedCost end) [Cost(2017)], Sum(case when Year(Time)=2016 then ExtendedPrice en
select
StoreID,
Sum(case when Year(Time)=2016 then ExtendedCost end) [Cost(2016)],
Sum(case when Year(Time)=2017 then ExtendedCost end) [Cost(2017)],
Sum(case when Year(Time)=2016 then ExtendedPrice end) [Sales(2016)],
Sum(case when Year(Time)=2017 then ExtendedPrice end) [Sales(2017)]
from F_itemDailySalesParent
这是4个不同的Case语句,只有一个选项。虽然我同意在SQL中这样做可能是最好的选择,但在Crystal中,我想我只会使用IF语句 4个公式 Cost2016公式
if {fieldforyear} = 2016 then {ExtendedCost}
if {fieldforyear} = 2016 then {ExtendedPrice}
Cost2017公式
if {fieldforyear} = 2017 then {ExtendedCost}
if {fieldforyear} = 2017 then {ExtendedPrice}
Sales2016配方奶粉
if {fieldforyear} = 2016 then {ExtendedCost}
if {fieldforyear} = 2016 then {ExtendedPrice}
Sales2017配方奶粉
if {fieldforyear} = 2017 then {ExtendedCost}
if {fieldforyear} = 2017 then {ExtendedPrice}
@CoSpringGuy我必须执行扩展成本总和,如果2016年,那么您的报告中应该有一个组。您可以在该组的摘要中使用上述公式…或在报告页脚中使用