[b]SQL分组、统计、排序的查询:[/b]
[b]还不知道怎么用“order by”来排序,像下面这样就会报错:[/b]
环境:MySQL5.0
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进行数据分组、统计及排序的基本方法。通过一个具体的例子展示了如何使用MySQL 5.0进行查询操作,包括使用count()函数进行计数、GROUP BY子句进行分组,并指出了ORDER BY子句在某些情况下的正确使用方式。
2953

被折叠的 条评论
为什么被折叠?



