没分了!保存中间值的问题
insert table1
select id,name,case when (select sum(table3.count) from table3
where table3.id=table2.id)>0 then (select sum(table3.count) from table3
where table3.id=table2.id) else 0 end
from table2
--------------------------------------------------------------------
问题:
then 后面的(select sum(table3.count) from table3
where table3.id=table2.id) else 0 end
总觉得麻烦,我应该怎么得到这个值,因为上面when 后面的语句和then 后面语句查询出来的结果是一样的,再有else 后面怎么用默认值?我用的是else default end
但是不行!报错!