MySQL Forums
Forum List  »  Docs

Joining columns of the same table
Posted by: Fadly Ismail
Date: August 02, 2010 03:02AM

Hi everybody.

I've got one problem in SQL query.

Let say I have a table below.
+--------+---------------+
| GENDER | DATE OF BIRTH |
+--------+---------------+
| MALE | JUN 15, 2010 |
| MALE | MAY 20, 2010 |
| FEMALE | MAY 25, 2010 |
| MALE | MAY 7, 2010 |
| FEMALE | JUL 3, 2010 |
| FEMALE | JUL 27, 2010 |
| MALE | MAY 18, 2010 |
| FEMALE | JUL 10, 2010 |
+--------+---------------+

How do I write the MySQL query so that it will count the total birth in every a month based on gender like this table below:
+--------+-----+-----+-----+
| GENDER | MAY | JUN | JUL |
+--------+-----+-----+-----+
| MALE | 3 | 1 | 0 |
| FEMALE | 1 | 0 | 3 |
+--------+-----+-----+-----+

Options: ReplyQuote


Subject
Views
Written By
Posted
Joining columns of the same table
4120
August 02, 2010 03:02AM
1948
September 15, 2010 11:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.