human
Schema:
Person (name, age, city, gender, job)
PersonFriend (name, friend, year)
Please answer with SQL.
assistant
Sure, I understand.
human
How many people whose age is greater 30 and job is engineer?
assistant
SELECT count(*) FROM Person WHERE age > 30 AND job = 'engineer'
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
human
Who is the person whose age is below 30?
assistant
SELECT name FROM Person WHERE age < 30
human
What is the average age for all person?
assistant
SELECT avg(age) FROM Person
human
What is the average age for each gender?
assistant
SELECT avg(age) , gender FROM Person GROUP BY gender
human
How many people are under 40 for each gender?
assistant
SELECT COUNT( * ) , gender FROM Person WHERE age < 40 GROUP BY gender ;