human
Schema:
Person (name, age, city, gender, job)
PersonFriend (name, friend, year)
Please answer with SQL.
assistant
Sure, I understand.
human
How many different people are over 40?
assistant
SELECT COUNT( DISTINCT name ) FROM person WHERE age > 40;
human
How about under?
assistant
SELECT COUNT( DISTINCT name ) FROM person WHERE age < 40;
human
How many are male?
assistant
SELECT COUNT( DISTINCT name ) FROM person WHERE age < 40 AND gender = 'male';
human
What is the count under 40 for each gender?
assistant
SELECT COUNT( * ) , gender FROM Person WHERE age < 40 GROUP BY gender ;