January 28, 2012

sort by occurence of anyvalue in a column

SELECT * , COUNT( ref ) AS occurances FROM table GROUP BY ref ORDER BY occurances DESC

No comments:

Post a Comment