Database schema:
CREATE TABLE Sailors (
  sid NUMBER PRIMARY KEY,
  name TEXT,
  rating NUMBER,
  age NUMBER
);
CREATE TABLE Boats (
  bid NUMBER PRIMARY KEY,
  name TEXT,
  color TEXT
);
CREATE TABLE Reserves (
  sid NUMBER,
  bid NUMBER,
  day TEXT,
  FOREIGN KEY (bid) REFERENCES Boats(bid),
  FOREIGN KEY (sid) REFERENCES Sailors(sid)
);

Question: What is average age of all sailors who have a rating of 7?
SQL: SELECT AVG(age) FROM Sailors WHERE rating  =  7

Question: How many boats are red?
SQL: SELECT count(*) FROM Boats WHERE color  =  'red'

Question: Find the names of sailors whose rating is larger than the rating of all sailors who booked a red boat.
SQL: SELECT name FROM Sailors WHERE rating  >  (SELECT max(T1.rating) FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T3.color  =  'red')

Question: Find the id of Sailors (sid) that reserved red and blue boat.
SQL: SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid WHERE T1.color  =  'red' INTERSECT SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid WHERE T1.color  =  "blue"

Question: What is the name of sailors whose names contain letter e?
SQL: SELECT name FROM Sailors WHERE name LIKE '%e%'

Question: What is the name, rating, and age for every sailor? And order them by rating and age.
SQL: SELECT name ,  rating ,  age FROM Sailors ORDER BY rating ,  age

Question: Return name and age for sailors who are younger than 30.
SQL: SELECT name ,  age FROM Sailors WHERE age  <  30

Question: Find the average rating and largest age for the sailors
SQL: SELECT AVG(rating) ,  MAX(age) FROM Sailors

Question: what is the name and id of sailors who do not have a reservation of a boat?
SQL: SELECT sid ,  name FROM Sailors EXCEPT SELECT T1.sid ,  T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid

Question: What is id about sailors who do not have boat reservations?
SQL: SELECT sid FROM Sailors EXCEPT SELECT T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid

Question: Return the unique boat ids (bid) of all reserved boats.
SQL: SELECT DISTINCT bid FROM Reserves

Question: What are the different boat ids reserved by the sailor whose id is 1?
SQL: SELECT DISTINCT bid FROM Reserves WHERE sid = 1

Question: Find the names of sailors who reserved boat with the name Melon.
SQL: SELECT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T3.name  =  'Melon'

Question: What is the name and age of every sailor who is younger than age 30?
SQL: SELECT name ,  age FROM Sailors WHERE age  <  30

Question: What are the ids of sailors who reserved red and blue boats?
SQL: SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid WHERE T1.color  =  'red' INTERSECT SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid WHERE T1.color  =  "blue"

Question: Find the number of reservations for each boat.
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid

Question: How many sailors exist?
SQL: SELECT COUNT(*) FROM Sailors

Question: what is the name and id of every sailor who has a rating greater than 2 and reserved a boat.
SQL: SELECT DISTINCT T1.name ,  T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid WHERE  T1.rating  >  2

Question: What is the different id of every sailor who is not the youngest?
SQL: SELECT DISTINCT sid FROM Sailors WHERE age  >  (SELECT min(age) FROM Sailors);

Question: Return the unique names of sailors who are older than any sailors whose rating is larger than 7.
SQL: SELECT DISTINCT name FROM Sailors WHERE age  >  (SELECT min(age) FROM Sailors WHERE rating  >  7);

Question: Find the id and name of the sailors who reserved more than one boat.
SQL: SELECT DISTINCT T1.name ,  T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid GROUP BY T2.sid HAVING COUNT(*)  >  1

Question: How many boats are there?
SQL: SELECT count(*) FROM Boats

Question: What is the name of all sailors whose rating is higher than any sailor named Luis?
SQL: SELECT name FROM Sailors WHERE rating  >  (SELECT min(rating) FROM Sailors WHERE name  =  'Luis')

Question: What are the names of sailors who reserved a boat with the name Melon?
SQL: SELECT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T3.name  =  'Melon'

Question: What are the different names of sailors who reserved two or more boats ?
SQL: select distinct t1.name ,  t1.sid from sailors as t1 join reserves as t2 on t1.sid  =  t2.sid group by t2.sid having count(*)  >=  2

Question: What can you tell me about sailors who are older than age 30?
SQL: SELECT * FROM Sailors WHERE age  >  30

Question: Find boats reserved by Sailor with id 1.
SQL: SELECT DISTINCT bid FROM Reserves WHERE sid = 1

Question: What are the names of the boats booked by people between age 20 and 30?
SQL: SELECT T3.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T1.age BETWEEN 20 AND 30

Question: What are the ids of sailors who have not reserved a boat?
SQL: SELECT sid FROM Sailors EXCEPT SELECT sid FROM Reserves

Question: What are the names of the sailors whose rating is larger than the rating of all sailors who booked a red boat?
SQL: SELECT name FROM Sailors WHERE rating  >  (SELECT max(T1.rating) FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T3.color  =  'red')

Question: How many red boats exist?
SQL: SELECT count(*) FROM Boats WHERE color  =  'red'

Question: How many reservations exist for each boat?
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid

Question: What is the rating and average age for sailors who have reserved red boat grouped by rating?
SQL: SELECT T1.rating ,  avg(T1.age) FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T3.color  =  'red' GROUP BY T1.rating

Question: What is the name of all sailors whose rating is higher than all sailors named Luis?
SQL: SELECT name FROM Sailors WHERE rating  >  (SELECT max(rating) FROM Sailors WHERE name  =  'Luis')

Question: Find the name of the sailors who reserved boat with id 103.
SQL: SELECT DISTINCT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid WHERE  T2.bid  =  103

Question: What are the names and ids of all sailors who have a rating of at least 3 and reserved a boat?
SQL: SELECT DISTINCT T1.name ,  T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid WHERE  T1.rating  >  2

Question: What is the name of every sailor whose name contains the letter e?
SQL: SELECT name FROM Sailors WHERE name LIKE '%e%'

Question: How many reservations for each boat did the sailors with an id greater than 1 make?
SQL: SELECT bid ,  count(*) FROM Reserves WHERE sid  >  1 GROUP BY bid

Question: Find the names of boats booked by sailors whose age is between 20 and 30.
SQL: SELECT T3.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid JOIN Boats AS T3 ON T3.bid  =  T2.bid WHERE T1.age BETWEEN 20 AND 30

Question: What is the name and age of the sailor with maximum age?
SQL: SELECT name ,  age FROM Sailors WHERE age  =  ( SELECT max(age) FROM Sailors )

Question: Find the name and id of Sailors (sid) that reserved red or blue boat.
SQL: SELECT DISTINCT T2.sid ,  T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid JOIN Sailors AS T3 ON T2.sid  =  T3.sid WHERE T1.color  =  'red' OR T1.color  =  "blue"

Question: how many sailors in total?
SQL: SELECT COUNT(*) FROM Sailors

Question: List the names and ages of all sailors sorted by rating in descending order.
SQL: SELECT name ,  age FROM Sailors ORDER BY rating DESC