分组子查询

  select t1.m,t1.pid ,max(t1.rel_energy) - min(t1.rel_energy) aa
from (
(select substring(t.cur_date from 1 for 10) as m,t.rel_energy,t.pid
  from t_electric_detail_copy t)  ) t1
group by t1.m,t1.pid order by pid

你可能感兴趣的:(子查询)