select *
from
itemcode_promotionexec
;
update itemcode_promotionexec
set serial2 = ''
where oldbillno = 'HDCL20220400388';
select distinct c.storecode,
count(case when c.serial2 is not null then c.serial2 else null end) as serial1,
count(case when len(c.serial2)>0 then c.serial2 else null end) as serial2,
sum(case when c.serial2 is not null then 1 else 0 end) as serial3
from itemcode_promotionexec c
group by c.storecode
为啥结果是2,不是0?
取serial1 2 3 4里面非空的个数
只能怀疑serial2里存在空格、回车或者不可见字符了,因为既不是NULL也不是空字符串,而且长度还大于0。
这数据库类型是什么?建议找下该数据库是否有查询数据的二进制或十六进制函数,看看这些空白的值到底是个什么东西