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 the ids of sailors that haven’t reserved a boat?
SQL: SELECT sid FROM Sailors EXCEPT SELECT sid FROM Reserves

Question: What are the names and ids of sailors who reserved red or blue boats?
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: What are the ids of all boats that are reserved by someone?
SQL: SELECT DISTINCT bid FROM Reserves

Question: What are the names of all sailors with a higher rating than every sailor named Luis?
SQL: SELECT name FROM Sailors WHERE rating  >  (SELECT max(rating) FROM Sailors WHERE name  =  'Luis')

Question: How many reservations exist for each boat with an id greater than 50?
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid HAVING bid  >  50

Question: How many reservations exist for each boat that has more than 1 reservation already?
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid HAVING count(*)  >  1

Question: What is the average age of sailors whose rating is 7?
SQL: SELECT AVG(age) FROM Sailors WHERE rating  =  7

Question: What are the average rating and max age of all sailors?
SQL: SELECT AVG(rating) ,  MAX(age) FROM Sailors

Question: What are the different names of sailors who are older than some other sailor with a rating larger than 7?
SQL: SELECT DISTINCT name FROM Sailors WHERE age  >  (SELECT min(age) FROM Sailors WHERE rating  >  7);

Question: Find the number of reservations for each boat with id greater than 50.
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid HAVING bid  >  50

Question: Find the name and id of the sailors who reserved at least one boat?
SQL: SELECT DISTINCT T1.name ,  T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid

Question: return the unique ids of sailors who are older than any sailors.
SQL: SELECT DISTINCT sid FROM Sailors WHERE age  >  (SELECT min(age) FROM Sailors);

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

Question: Find the number of reservations for each boat with more than 1 reservation.
SQL: SELECT bid ,  count(*) FROM Reserves GROUP BY bid HAVING count(*)  >  1

Question: What is 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: Find the name and id of Sailors (sid) that reserved red and 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' INTERSECT 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  =  "blue"

Question: What are the sids for sailors who reserved red or blue boats?
SQL: SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON  T1.bid  =  T2.bid WHERE T1.color  =  'red' OR T1.color  =  "blue"

Question: What is the name of the sailor who reserved boat 102?
SQL: SELECT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid  =  T2.sid WHERE T2.bid  =  102

Question: Find the name and age of the oldest sailor.
SQL: SELECT name ,  age FROM Sailors WHERE age  =  ( SELECT max(age) FROM Sailors )

Question: What is the count of the sailors whose name starts with letter D ?
SQL: select count(*) from sailors where name like 'd%'