SQLServer查询虚字段可以设置类型么?
select DICount,(ISNULL(DIClickCount,0)) as ClickCount,(case ISNULL(DICount,0) when 0 then 0 elseISNULL(DIClickCount,0)/DICount end) as ClickConvert,ISNULL(DI_EffectCount,0) as EffectCount,(case ISNULL(DI_EffectCount,0) when 0 then 0 elseisNull(DI_EffectCount,0)/DICount end) as EffectConvert from SK_DetailInfo
select DICount,(ISNULL(DIClickCount,0)) as ClickCount,(case ISNULL(DICount,0) when 0 then 0 else 1.00*ISNULL(DIClickCount,0)/DICount end) as ClickConvert,ISNULL(DI_EffectCount,0) as EffectCount,(case ISNULL(DI_EffectCount,0) when 0 then 0 elseisNull(DI_EffectCount,0)/DICount end) as EffectConvert from SK_DetailInfo
[解决办法]
cast((case ISNULL(DICount,0) when 0 then 0 elseISNULL(DIClickCount,0)*1./DICount end) as decimal(8,2)) as ClickConvert