You can include the conditions in the where clause in a case expression. Be sure to not include an else clause in the case expression.select
avg(case when Occupation='student' AND Gender='M' then Age end) as AvgMStudent,
avg(case when Occupation='student' AND Gender='F' then Age end) as AvgFStudent