SELECT DISTINCT 和 ORDER BY 相同值的数量
SELECT DISTINCT and ORDER BY number of same values
我的代码:我需要什么功能来执行这样的功能?
SELECT DISTINCT word
FROM Table
ORDER BY ??? -- number of equal words in descending order
示例:我有以下数据
Word
----
are
are
are
we
we
we
we
is
is
you
期望输出:(在 运行 查询之后)
Word
----
we
are
is
you
你应该使用 GROUP BY
然后 ORDER
:
SELECT word
FROM Table
GROUP BY Word
ORDER BY COUNT(*) DESC
我的代码:我需要什么功能来执行这样的功能?
SELECT DISTINCT word
FROM Table
ORDER BY ??? -- number of equal words in descending order
示例:我有以下数据
Word
----
are
are
are
we
we
we
we
is
is
you
期望输出:(在 运行 查询之后)
Word
----
we
are
is
you
你应该使用 GROUP BY
然后 ORDER
:
SELECT word
FROM Table
GROUP BY Word
ORDER BY COUNT(*) DESC