Archive

Posts Tagged ‘count’

MySql count width if statement grouped

November 21st, 2009 wiley No comments

Table name – firms

Firm Sex
firm1 man
firm2 man
firm2 woman
SELECT Firm, SUM(IF(sex='man',1,0)) AS Man, SUM(IF(sex='woman',1,0)) AS Woman FROM firms GROUP BY Firm;
Firm Man Woman
firm1 1 0
firm2 1 1

Unique visitors to post: 8

Categories: MySQL Tags: , , ,
Google Analytics integration offered by Wordpress Google Analytics Plugin