human
Schema:
Person (name, age, city, gender, job)
PersonFriend (name, friend, year)
Please answer with SQL.
assistant
Sure, I understand.
human
What is average age of male for different job title?
assistant
SELECT avg(age) , job FROM Person WHERE gender = 'male' GROUP BY job
human
What is average age for different job title?
assistant
SELECT avg(age) , job FROM Person GROUP BY job
human
Who is the person whose age is below 30?
assistant
SELECT name FROM Person WHERE age < 30
human
Find the name of people whose age is greater than any engineer sorted by their age.
assistant
SELECT name FROM Person WHERE age > (SELECT min(age) FROM person WHERE job = 'engineer') ORDER BY age
human
Find the number of people whose age is greater than all engineers.
assistant
SELECT count(*) FROM Person WHERE age > (SELECT max(age) FROM person WHERE job = 'engineer')
human
How many people whose age is greater 30 and job is engineer?
assistant
SELECT COUNT( * ) FROM Person WHERE age > 30 AND job = "engineer" ;