Forums

This topic is locked

SQL question

Posted 15 Aug 2001 21:42:27
1
has voted
15 Aug 2001 21:42:27 Mark Labordus posted:
This is what I have:
SELECT ROUND((TO_DAYS(NOW())-TO_DAYS(birthdate))/365) as age, if(gender = 'M', COUNT(*), 0) as male, if (gender = 'F', COUNT(*), 0) as female
FROM users
GROUP BY age, gender

This is the result:
age, male, female
20 , 12 , 0
21 , 0 , 3
24 , 8 , 0
24 , 0 , 6
What I want is that the last two results are shown together, I mean like this:
24, 8, 6

DOes anyone know how to do this?



Replies

Replied 15 Aug 2001 23:30:38
15 Aug 2001 23:30:38 Joel Martinez replied:
the reason you're getting that, is because the query is being group the by the Gender, thus it wont combine results that have more than one gender.
see if you can just get rid of the gender in the group by... that should work.

(BTW, Great Query)

Joel Martinez

----------
set rs = conn.execute("SELECT answer FROM brain WHERE question = "& forumPost &"

Reply to this topic