Skip to main content

SORT BASE ON COUNT

Query to select feilds group by column and order by number of counts of feilds.

|| SELECT type, count(*) FROM vehicles group by type order by count(*) desc

 

|| SELECT `userid`, count(*) FROM `library` group by `userid` order by count(*) desc

 

|| SELECT `userid`, count(favourite) FROM `library` group by `userid` order by count(favourite) desc

 
ERROR : SELECT list is not in GROUP BY clause and contains nonaggregated column … incompatible with sql_mode=only_full_group_by

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); 



Comments