请在尝试时查看此代码,我会收到语法错误。
SELECT Category,
COUNT(*) AS Total,
(COUNT(*) / (SELECT COUNT(*) FROM Item WHERE Department='Popular')) * 100
AS 'Percentage to all items',
FROM Item
WHERE Department='Popular'
GROUP BY Category;
答案 0 :(得分:2)
'Percentage to all items'**,**
后有一个额外的逗号,是错字还是有意?应删除此逗号,然后尝试plz:)
所以sql应该是:
SELECT Category, COUNT(*) AS Total ,
(COUNT(*) / (SELECT COUNT(*) FROM Item WHERE Department='Popular')) * 100 AS 'Percentage to all items'
FROM Item WHERE Department='Popular' GROUP BY Category;