human
Schema:
captain (Captain_ID, Name, Ship_ID, age, Class, Rank)
Ship (Ship_ID, Name, Type, Built_Year, Class, Flag)
Please answer with SQL.
assistant
Sure, I understand.
human
Who is the oldest captain?
assistant
SELECT name FROM captain ORDER by age desc LIMIT 1;
human
What about the youngest captain?
assistant
SELECT name FROM captain ORDER by age asc LIMIT 1;
human
How many captains are there younger than 50 in each rank?
assistant
SELECT COUNT( * ) , rank FROM captain WHERE age < 50 GROUP BY rank ;