Home > MySQL > MySql count width if statement grouped

MySql count width if statement grouped

November 21st, 2009 wiley Leave a comment Go to 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: , , ,
  1. No comments yet.
  1. No trackbacks yet.
Google Analytics integration offered by Wordpress Google Analytics Plugin