sql - mysql result using query -


i've got table in mysql 2 two fields (age, sex) need avg(age) sex (m or f), can me solve ? how should 1 query getting both of looks like?

try this:

   select   avg(case when sex = 'm' age end) avg_male ,  avg(case when sex = 'f' age end) avg_female ,  name,  book_date  reviews r  inner join books b  on b.id = r.book_id  age<30        <--------------  group book_id    <-------- can group here column like. 

demo here


Comments

Popular posts from this blog

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -