成都电视广播大学:ASP中如何进行〔数据分类〕统计

来源:百度文库 编辑:高校问答 时间:2024/04/29 14:31:56
我有一个product表,其中的“pdname”字段是产品名,“class”字段是类别。现在需要对满足class=1这个条件的所有产品进行分类统计。代码怎么写啊

count(XXX)as XXX只能统计出总数,但我需要的是分类统计数

比如product中所有的“pdname=苹果”且class=1的统计数。
所有“pdname=香焦”且class=1的统计数

总之能将pdname中所有的值并且满足class=1的数据统计出来就应。

谢谢大家了!

苹果 3
香焦 5
梨子 4

select count(pdname) from product where class=1 group by pdname

select count(pdname) from product where class=1 group by pdname

http://club.heima.com/forum_display.aspx?forumid=100484&categoryid=116
http://club.heima.com/forum_display.aspx?forumid=100484&categoryid=116