select (select j.jgmc from t_zzjg j where j.jgdm = t.jgdm) jgmc,
t.jgdm,
sum(t.jcj) jcj,
sum(t.sa) sa,
sum(t.la) la,
sum(t.ajbl) ajbl,
sum(t.xsqzcs) xsqzcs,
sum(t.sacw) sacw,
sum(t.jgzx) jgzx,
sum(t.zfgz) zfgz,
sum(t.jjclaj) jjclaj,
sum(t.zs) zs
from t_fxyp_zfycfbtj t
where t.rq between to_date(2013 - 01 - 18 , 'YYYY-MM-DD') and
to_date(2013 - 07 - 18 , 'YYYY-MM-DD')
and exists (select z.jgdm
from t_zzjg z
where (z.dwlx = 'SJ' or z.sjjgdm is null)
and z.jgdm = t.jgdm)
group by t.jgdm
order by t.jgdm
正确语句
select to_date('2012-05-06 12:05:03','yyyy-mm-dd hh24:mi:ss') from dual
select to_date('2012-05-06','yyyy-mm-dd hh24:mi:ss') from dual
select to_date('2012-05-06','yyyy-mm-dd') from dual