gridview中绑定数据库后,数据库中有值是空的,怎么把空的值显示为0呢?

来源:百度知道 编辑:UC知道 时间:2024/04/29 01:24:07
数据库是客户送来的,我不能改,而且数据库很考验我的水平,查询语句我是这样的,谁能帮我改改
select a.unit_desc,
max(case t when 1 then y end) as A,
max(case t when 2 then y end) as B,
max(case t when 3 then y end) as C,
max(case t when 4 then y end) as D
from PAS_B_UNIT a left outer join pas_cus_sall_targetyear b on a.unit_id=b.unit_id and b.t_year=2009 group by a.unit_desc

如果这里不能改,gridview那里有什么可以改的吗

哪个字段可能为空呢?如果max(case t when 1 then y end)可能为空的话,你这样写isnull(max(case t when 1 then y end),0),其他的依次类推,你试一试!

建议你在建库的时候采用默认值 可以把有空值的字段默认设为0