SQL Query添加唯一字符串出现次数

时间:2011-03-17 20:31:12

标签: sql add

例如,如果我正在创建一个披萨商店数据库,它将看起来像这样

http://i.stack.imgur.com/xQGUY.png

2 个答案:

答案 0 :(得分:7)

SELECT pizza_type, COUNT(*) as 'NumberOrdered'
FROM table
GROUP BY pizza_type

答案 1 :(得分:6)

查看COUNT()函数和GROUP BY

select pizza_type, count(*) as NumberOrdered
from orders
group by pizza_type