select (case
when a.iscashvirtual = '1' then
'type1'
when a.isbillvirtual = '1' then
'type2'
else
case
when a.deposittype = '1' then
'type3'
when a.deposittype = '2' then
'type4'
when a.deposittype = '3' then
'type5'
else
'其他'
end end) savetype,
sum(b.closingbalance) sums
From eee a,bbb b
类似上面的SQL,查询的savetype会有5种类型,需要这5种数据都有,但是数据库中查出来的可能没有该类型。那么不存在的类型就加上该类型且sums的值设为0。现在要求用sql语句实现,我没办法,这个可以通过sql解决吗?如果有求解决方法