comparision of two columns within a single table
i have a table开发者_开发知识库 alpha ,this contains two columns A And B. I need to find out how many A's are there for B.
A B
1 1
2 2
3 3
4 3
5 4
6 7
Try grouping :
SELECT `B`, COUNT(*) AS `Count`
FROM `Alpha`
GROUP BY `B`
try this
SELECT COUNT( * ) AS `Items` , `B`
FROM `alpha`
GROUP BY `b`
精彩评论