orderby与groupby同时使用方法
发布时间:2015-06-05 来源:查字典编辑
摘要:1.SELECTSale.BaoBeiName,Count(*)AS销售量FROMSaleGROUPBYSale.BaoBeiNameord...
1.
SELECT Sale.BaoBeiName, Count(*) AS 销售量
FROM Sale
GROUP BY Sale.BaoBeiName order by Count(*) desc;
2.
SELECT Sale.BaoBeiName, sum(*) AS 合计 FROM Sale
GROUP BY Sale.BaoBeiName order by sum(*) desc;