select un.name, count(u.id) as count from users u, unis un where un.id=u.uni_id group by uni_id, un.name order by count desc; select un.name, s1.count as female, s2.count as male, 1.0*s1.count/s2.count as quote from unis un, sex_by_uni s1, sex_by_uni s2 where s1.uni_id=s2.uni_id and s1.uni_id=un.id and s1.sex=1 and s2.sex=2 and s1.count+s2.count>50 order by quote desc; select extract('year' from age(birthdate)) as age, count(*), 0 as sex from user_data where birthdate > date '1950-01-01' and birthdate < date '2000-01-01' group by age union select extract('year' from age(birthdate)) as age, count(*), sex from user_data where birthdate > date '1950-01-01' and birthdate < date '2000-01-01' group by age, sex order by sex, age; select avg(count), max(count) from groups_per_user; select avg(count), max(count) from users_per_group; select c.name, s1.count as female, s2.count as male, 1.0*s1.count/s2.count as quote from concentrations c, sex_by_concentration s1, sex_by_concentration s2 where c.id=s1.concentration_id and s1.concentration_id=s2.concentration_id and s1.sex=1 and s2.sex=2 and s1.count+s2.count>50 order by quote desc; select c.name, s1.count as female, s2.count as male, 1.0*s1.count/s2.count as quote from courses c, sex_by_course s1, sex_by_course s2 where c.id=s1.course_id and s1.course_id=s2.course_id and s1.sex=1 and s2.sex=2 and s1.count+s2.count>50 order by quote desc; select vorname, count(vorname) as anzahl, extract('year' from min(birthdate)) as min_bday, extract('year' from max(birthdate)) as max_bday, extract('year' from avg(age(birthdate))) as avg_age from users u, user_data ud where u.id=ud.id group by vorname having min(birthdate) != max(birthdate) and count(vorname)>5 order by vorname;