human
Schema:
Person (name, age, city, gender, job)
PersonFriend (name, friend, year)
Please answer with SQL.
assistant
Sure, I understand.
human
What is the average age for each gender?
assistant
SELECT avg(age) , gender FROM Person GROUP BY gender
human
Who is the youngest male?
assistant
SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT min(age) FROM person WHERE gender = 'male' )
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 who is under 40 for each gender.
assistant
SELECT count(*) , gender FROM Person WHERE age < 40 GROUP BY gender
human
Find the names of all person sorted in the descending order using age.
assistant
SELECT name FROM Person ORDER BY age DESC
human
Find the name and age of all males in order of their age.
assistant
SELECT name FROM Person WHERE gender = "male" ORDER BY age ;