select sum(j.length),sum(d.length)
from (res_xl_gdgx x left join res_jkx_info j on j.ssgdgx = x.ssgdgx) left join res_dl_info d d.ssgdgx,0,21 = x.ssgdgx
where x.id = 'XIL0010494' group by x.Mc这样sum(d.length)的结果怎么不准呢。。该怎么写呢,各位帮帮忙!
from (res_xl_gdgx x left join res_jkx_info j on j.ssgdgx = x.ssgdgx) left join res_dl_info d d.ssgdgx,0,21 = x.ssgdgx
where x.id = 'XIL0010494' group by x.Mc这样sum(d.length)的结果怎么不准呢。。该怎么写呢,各位帮帮忙!
UNION
select x.mc, sum(d.length) from res_xl_gdgx x , res_dl_info d where substr(d.ssgdgx,0,21) = x.ssgdgx || x.id and x.id = 'XIL0010494' group by x.Mc最简单的方法
select mc,sum(length)length
from (
select x.mc, sum(j.length)length from res_xl_gdgx x , res_jkx_info j where substr(j.ssgdgx,0,21) = x.ssgdgx || x.id and x.id = 'XIL0010494' group by x.Mc
UNION
select x.mc, sum(d.length)length from res_xl_gdgx x , res_dl_info d where substr(d.ssgdgx,0,21) = x.ssgdgx || x.id and x.id = 'XIL0010494' group by x.Mc) a
group by mc
from (
select x.mc, sum(j.length)jlength,0 dlength from res_xl_gdgx x , res_jkx_info j
where substr(j.ssgdgx,0,21) = x.ssgdgx || x.id and x.id = 'XIL0010494'
group by x.Mc
UNION
select x.mc,0 jlength, sum(d.length)dlength from res_xl_gdgx x , res_dl_info d
where substr(d.ssgdgx,0,21) = x.ssgdgx || x.id and x.id = 'XIL0010494'
group by x.Mc
) a
group by mc