欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SQL分组、统计、排序的查询

程序员文章站 2022-06-05 09:18:22
...
[b]SQL分组、统计、排序的查询:[/b]

SELECT count( id ) cnt, category, computername
FROM `computer`
WHERE (
category = 'notebook'
OR category = 'desk-top'
)
GROUP BY computername ASC
LIMIT 0 , 100

[b]还不知道怎么用“order by”来排序,像下面这样就会报错:[/b]

SELECT count( id ) cnt, category, computername
FROM `computer`
WHERE (
category = 'notebook'
OR category = 'desk-top'
)
ORDER BY computername
GROUP BY computername
LIMIT 0 , 100


环境:MySQL5.0
相关标签: SQL