select ec.id,classDate from ea_curriculum ec order by classDate < DATE_FORMAT(now(), '%Y-%m-%d'),if(classDate < now(),0,classDate),classDate desc