SQL Server中如何把count为空的显示为0

2025-02-25 19:16:14
推荐回答(1个)
回答1:

这样?

select lx,sum(cnt) from 
(select lx,count(lx) cnt from test where lx = '2' group by lx
union all
select 2,0) t
group by lx