错误SQL:
select day(visit_date) time, count(if(behavior_type=4,1,NULL)), count(if(behavior_type<>4,1,NULL)), count(if(behavior_type=4,1,NULL))/count(if(behavior_type<>4,1,NULL)) from big group by day(visit_date) order by day(visit_date);
select day(visit_date) time, count(if(behavior_type=4,1,NULL)), count(if(behavior_type<>4,1,NULL)), count(if(behavior_type=4,1,NULL))/count(if(behavior_type<>4,1,NULL)) from big group by time order by time;
order by的时候使用别名,就能够执行过去
正确SQL:
select day(visit_date) time, count(if(behavior_type=4,1,NULL)), count(if(behavior_type<>4,1,NULL)), count(if(behavior_type=4,1,NULL))/count(if(behavior_type<>4,1,NULL)) from big group by day(visit_date) order by time;



