我有一个简单的CASE语句,在我的ELSE块数字列中我想显示为' - '。 但它给了我一个错误
Arithmetic overflow error converting varchar to data type numeric.
SELECT
CASE WHEN ChargeName = 'Premium' THEN CompanyCommissionPercentage ELSE '-' END AS CompanyCommissionPercentage
,CASE WHEN ChargeName = 'Premium' THEN RemitterCommissionPercentage ELSE '-' END AS RemitterCommissionPercentage
,CASE WHEN ChargeName = 'Premium' THEN RemitterCommission ELSE '-'END AS RemitterCommission
,CASE WHEN ChargeName = 'Premium' THEN GrossCommission ELSE '-'END AS GrossCommission
FROM @tmpAccountsPayable
答案 0 :(得分:2)
`SELECT
CASE WHEN ChargeName = 'Premium' THEN CAST(CompanyCommissionPercentage as varchar(10)) ELSE CAST('-' as varchar(10)) END AS CompanyCommissionPercentage
FROM @tmpAccountsPayable`
答案 1 :(得分:0)