如果在结果集中值为'-'
时如何插入0.00
,则水晶报表中的摘要不起作用?
Create Table #Results
(
TerminalNumber INT,
ContractNumber VARCHAR(50),
CustomerName VARCHAR(80),
TotalDeficiency NUMERIC(13,2),
TotalIncremental NUMERIC(13,2),
MonthPeriod VARCHAR(20)
)
SELECT TerminalNumber
,ContractNumber
,CustomerName
,CASE WHEN TotalDeficiency = 0.00 THEN '-' ELSE CAST(TotalDeficiency AS NUMERIC(13,2)) END AS TotalDeficiency
,CASE WHEN TotalIncremental = 0.00 THEN '-' ELSE CAST(TotalIncremental AS NUMERIC(13,2)) END AS TotalIncremental
,MonthPeriod
,CONVERT(VARCHAR(10), @billing_date, 101) 'BillingDate'
FROM #Results order by CustomerName
答案 0 :(得分:4)
如果您在演示文稿中需要,可以使用CASE
。
SELECT
CASE
WHEN TotalDeficiency = 0.00 THEN '-'
ELSE CAST(TotalDeficiency AS VARCHAR(10))
END AS TotalDeficiency
FROM #Results;
如果使用IIF
,请或SQL Server 2012+
SELECT
IIF(TotalDeficiency = 0.00, '-', CAST(TotalDeficiency AS VARCHAR(10)) )
AS TotalDeficiency
FROM #Results;
的 LiveDemo
强>
但您无法在-
列中插入字符MONEY
。