鉴于:
表叫names用id,first和last领域.
你怎么会被发现发生的前5名最受欢迎的人时,first和last是分开的领域?这是我现在的非工作代码......
`SELECT *, COUNT(first) AS occurrences FROM `names` GROUP BY first ORDER BY occurrences DESC LIMIT 5`
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
Gal*_*alz 10
对于前5名,请尝试:
SELECT first, COUNT(*) AS occurrences
FROM names
GROUP BY first
ORDER BY occurrences DESC
LIMIT 5
Run Code Online (Sandbox Code Playgroud)
对于前5名,请尝试:
SELECT first, last, COUNT(*) AS occurrences
FROM names
GROUP BY first, last
ORDER BY occurrences DESC
LIMIT 5
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3528 次 |
| 最近记录: |