优化问题急
utpcb 2011-11-09 08:55:17
select m.c5 c5,m.co co,max(m.c1) c1 from ST1401_main m join (
select c5,co, CAST(date_add(max(c1),interval -1 month) AS UNSIGNED) c1 ,max(c1) from ST1401_main
where c5>=20111231000000 and c5<=20121231000000 group by c5,co ) n on m.c5=n.c5 and m.co=n.co and
m.c1<n.c1 group by m.c5,m.co
1 PRIMARY <derived2> ALL \N \N \N \N 4686 Using temporary; Using filesort
1 PRIMARY m ref PRIMARY,C1,C5,C5COC1 C5COC1 107 n.c5,n.co 296 Using where; Using index
2 DERIVED ST1401_main range C5,C5COC1 C5COC1 107 \N 6055 Using where; Using index for group-by
就是第一步那个应该 怎么优化呢