按计数从列顺序中选择唯一值

时间:2015-03-12 23:21:14

标签: php mysql

我使用此代码:

$sql = "SELECT DISTINCT(name) AS name FROM Tags  ORDER BY name DESC"

但是我如何通过计算值对它进行排序?

类似的东西:

$sql = "SELECT DISTINCT(name) AS name FROM Tags  ORDER BY count(name) DESC"

1 个答案:

答案 0 :(得分:0)

  

SQL Fiddle

SELECT count(name) as count, name
FROM Tags
GROUP BY name
ORDER BY count DESC;