--disable_warnings drop table if exists t1; --enable_warnings set @@sql_mode='TRADITIONAL'; create table t1 (a int, b int); insert into t1 values (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); # # test with count(*) # select count(*) from t1; select 1 from t1 order by count(*) ; --error ER_CON_COUNT_ERROR select count(*), a from t1; # error ? select a from t1 having count(*); select a from t1 order by count(*); # # test with count(b) # select count(b) from t1; select 1 from t1 order by count(b) ; # error ? select a from t1 order by count(b) ; select a from t1 having count(b); select a from t1 order by count(b); # # test with sum(b) # select sum(b) from t1; select 1 from t1 order by sum(b) ; # error ? select a from t1 order by sum(b) ; select a from t1 having sum(b); select a from t1 order by sum(b); # # ONLY_FULL_GROUP_BY # set @@sql_mode='ONLY_FULL_GROUP_BY'; # # test with count(*) # select count(*) from t1; select 1 from t1 order by count(*) ; --error ER_CON_COUNT_ERROR select count(*), a from t1; # error ? select a from t1 having count(*); select a from t1 order by count(*); # # test with count(b) # select count(b) from t1; select 1 from t1 order by count(b) ; # error ? select a from t1 order by count(b) ; select a from t1 having count(b); select a from t1 order by count(b); # # test with sum(b) # select sum(b) from t1; select 1 from t1 order by sum(b) ; # error ? select a from t1 order by sum(b) ; select a from t1 having sum(b); select a from t1 order by sum(b);