from ( select .. from hissubstationmeasure e where e.dtime between
to_date('2013-12-31 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and
to_date('2013-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) e
left join (select ..tblsubstation n where n.used = 1)n
on e.id = n.id
left join tblsubcontrolarea a
on n.subcontrolareaid = a.id
group by a.id, a.name;试试
to_date('2013-12-31 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and
to_date('2013-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) e
left join (select ..tblsubstation n where n.used = 1)n
on e.id = n.id
left join tblsubcontrolarea a
on n.subcontrolareaid = a.id
group by a.id, a.name;试试
and e.dtime<=to_date('2013-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss').left join tblsubstation n
on e.id = n.id
left join tblsubcontrolarea a 先联合这2表子查询查在关联大表会不会好点。试试看
to_date('2013-12-31 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and
to_date('2013-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')
试试 用substr,and stat_date like substr(v_last_date,1,6)||'%';