select t.MR_TOTALMILE from t_monit_real_94_730 t where TO_CHAR(t.MR_DATE,'yyyy-MM-dd HH24:mi:ss') in (SELECT MIN(TO_CHAR(B.MR_DATE, 'yyyy-MM-dd HH24:mi:ss')) MR_DATE FROM (SELECT T.*,TO_CHAR(MR_DATE, 'yyyy-MM-dd') today_start,TO_CHAR(MR_DATE, 'yyyy-MM-dd') today_end FROM t_monit_real_94_730 T ) B where TO_CHAR(B.MR_DATE,'yyyy-MM-dd HH24:mi:ss') BETWEEN '2013-12-02 00:00:50' AND '2013-12-28 23:59:55' GROUP BY B.CAR_ID, today_start, today_end) ORDER BY t.MR_TOTALMILE;
union all
select t.MR_TOTALMILE from t_monit_real_94_730 t where TO_CHAR(t.MR_DATE,'yyyy-MM-dd HH24:mi:ss') in (SELECT MAX(TO_CHAR(B.MR_DATE, 'yyyy-MM-dd HH24:mi:ss')) MR_DATE FROM (SELECT T.*,TO_CHAR(MR_DATE, 'yyyy-MM-dd') today_start,TO_CHAR(MR_DATE, 'yyyy-MM-dd') today_end FROM t_monit_real_94_730 T ) B where TO_CHAR(B.MR_DATE,'yyyy-MM-dd HH24:mi:ss') BETWEEN '2013-12-02 00:00:50' AND '2013-12-28 23:59:55' GROUP BY B.CAR_ID, today_start, today_end) ORDER BY t.MR_TOTALMILE;
是要变成两行话union all就可以啦
如果要变成一行两列的话就用join