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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

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

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -