Database schema:
CREATE TABLE Artists (
  artistID NUMBER PRIMARY KEY,
  lname TEXT,
  fname TEXT,
  birthYear NUMBER,
  deathYear NUMBER
);
CREATE TABLE Paintings (
  paintingID NUMBER PRIMARY KEY,
  title TEXT,
  year NUMBER,
  height_mm NUMBER,
  width_mm NUMBER,
  medium TEXT,
  mediumOn TEXT,
  location TEXT,
  painterID NUMBER,
  FOREIGN KEY (painterID) REFERENCES Artists(artistID)
);
CREATE TABLE Sculptures (
  sculptureID NUMBER PRIMARY KEY,
  title TEXT,
  year NUMBER,
  medium TEXT,
  location TEXT,
  sculptorID NUMBER,
  FOREIGN KEY (sculptorID) REFERENCES Artists(artistID)
);

Question: What are the titles of all paintings and sculpture works made by the artist whose id is 222?
SQL: SELECT T2.title FROM artists AS T1 JOIN paintings AS T2 ON T1.artistID  =  T2.painterID WHERE T1.artistID  =  222 UNION SELECT T4.title FROM artists AS T3 JOIN sculptures AS T4 ON T3.artistID  =  T4.sculptorID WHERE T3.artistID  =  222

Question: What are the first name and age of the artist who had the longest life?
SQL: SELECT fname  ,  deathYear - birthYear FROM artists ORDER BY deathYear - birthYear DESC LIMIT 1

Question: What is the total number of paintings exhibited in gallery 240?
SQL: SELECT count(*) FROM paintings WHERE LOCATION  =  "Gallery 240"

Question: What locations have works painted before 1885 or after 1930?
SQL: SELECT DISTINCT LOCATION FROM paintings WHERE YEAR  < 1885 OR YEAR  >  1930

Question: Give the full names of artists who have created paintings and sculptures.
SQL: SELECT T1.lname ,  T1.fname FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID INTERSECT SELECT T3.lname ,  T3.fname FROM artists AS T3 JOIN paintings AS T4 ON T3.artistID  =  T4.painterID

Question: What are the sculptures called and where are they located?
SQL: SELECT title ,  LOCATION FROM sculptures

Question: List the year, location, and name of all paintings that are taller than 1000 in alphabetical order.
SQL: SELECT title ,  LOCATION ,  YEAR FROM paintings WHERE height_mm  >  1000 ORDER BY title

Question: What is the birth year of each distinct artists who created sculptures after 1920?
SQL: SELECT DISTINCT T1.birthYear FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID WHERE T2.year  >  1920

Question: What are the names of  paintings and scupltures created between 1900 and 1950?
SQL: SELECT title FROM paintings WHERE YEAR BETWEEN 1900 AND 1950 UNION SELECT title FROM sculptures WHERE YEAR BETWEEN 1900 AND 1950

Question: How many works are there in each medium?
SQL: SELECT count(*) ,  medium FROM paintings GROUP BY medium

Question: What is the name of the oldest painting and where is it located?
SQL: SELECT title ,  LOCATION ,  YEAR FROM paintings ORDER BY YEAR LIMIT 1

Question: What are the ids of the paintings whose height is longer than the height of all paintings created after 1900?
SQL: SELECT paintingID FROM paintings WHERE height_mm  >   (SELECT max(height_mm) FROM paintings WHERE YEAR  >  1900)

Question: What are the id and height of the painting with the longest width in gallery 240?
SQL: SELECT paintingID ,  height_mm FROM paintings WHERE LOCATION  =  'Gallery 240' ORDER BY width_mm DESC LIMIT 1

Question: What is the id of every painting created before the oldest painting in gallery 240?
SQL: SELECT paintingID FROM paintings WHERE YEAR  <   (SELECT min(YEAR) FROM paintings WHERE LOCATION  =  'Gallery 240')

Question: What are the maximum height and id of paintings painted before 1900?
SQL: SELECT max(height_mm) ,  paintingID FROM paintings WHERE YEAR  <  1900

Question: Find the id of the oldest painting.
SQL: SELECT paintingID FROM paintings ORDER BY YEAR LIMIT 1

Question: What are the names and dates created for all sculptures not located in gallery 226?
SQL: SELECT title ,  YEAR FROM sculptures WHERE LOCATION != "Gallery 226"

Question: What is the first name of the artist who has the highest number of sculptures?
SQL: SELECT T1.fname FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID GROUP BY T2.sculptorID ORDER BY count(*) DESC LIMIT 1

Question: What is the name of the scuplture that was created most recently ?
SQL: select title from sculptures order by year desc limit 1

Question: Find the death year of all artists who have at most 3 paintings?
SQL: SELECT T1.deathYear FROM artists AS T1 JOIN paintings AS T2 ON T1.artistID  =  T2.painterID GROUP BY T2.painterID HAVING count(*)  <=  3

Question: Find the ids of paintings whose height is bigger than 500 and less than 2000?
SQL: SELECT paintingID FROM paintings WHERE height_mm  >  500 AND height_mm  <  2000

Question: What are the paintings called and where are they located?
SQL: SELECT title ,  LOCATION FROM paintings

Question: How many paintings are exhibited at gallery 240?
SQL: SELECT count(*) FROM paintings WHERE LOCATION  =  "Gallery 240"

Question: What are the first names of all artists who have at least two paintings, and how many works did each create?
SQL: SELECT T1.fname ,  count(*) FROM artists AS T1 JOIN paintings AS T2 ON T1.artistID  =  T2.painterID GROUP BY T2.painterID HAVING count(*)  >=  2

Question: When did the artist who made the fewest sculptures die?
SQL: SELECT T1.deathYear FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID GROUP BY T2.sculptorID ORDER BY count(*) LIMIT 1

Question: What is the first name and age of the artist who lived the longest?
SQL: SELECT fname  ,  deathYear - birthYear FROM artists ORDER BY deathYear - birthYear DESC LIMIT 1

Question: What are the maximum height and width of paintings for each year?
SQL: SELECT max(height_mm) ,  max(width_mm) ,  YEAR FROM paintings GROUP BY YEAR ORDER BY YEAR

Question: Find the distinct titles of all the paintings that have a longer height than some painting on canvas?
SQL: SELECT DISTINCT title FROM paintings WHERE height_mm  >  (SELECT min(height_mm) FROM paintings WHERE mediumOn  =  "canvas")

Question: What is the average height and width of paintings that are oil medium in gallery 241?
SQL: SELECT avg(height_mm) ,  avg(width_mm) FROM paintings WHERE medium  =  "oil" AND LOCATION  =  "Gallery 241"

Question: Find the locations that have paintings created before 1885 and after 1930?
SQL: SELECT DISTINCT LOCATION FROM paintings WHERE YEAR  <  1885 INTERSECT SELECT DISTINCT LOCATION FROM paintings WHERE YEAR  >  1930

Question: What is the id of the artist who has the highest number of painting works before 1900?
SQL: SELECT T1.artistID FROM artists AS T1 JOIN paintings AS T2 ON T1.artistID  =  T2.painterID WHERE T2.year  <  1900 GROUP BY T1.artistID ORDER BY count(*) DESC LIMIT 1

Question: Order all of the oil paintings by date of creation and list their ids, locations, and titles.
SQL: SELECT paintingID ,  title ,  LOCATION FROM paintings WHERE medium  =  "oil" ORDER BY YEAR

Question: What are the distinct ids of every painting that is older than some painting in gallery 240?
SQL: SELECT paintingID FROM paintings WHERE YEAR  <  (SELECT max(YEAR) FROM paintings WHERE LOCATION  =  "Gallery 240")

Question: What are the first and last name of the artist who had a sculpture work whose title has the word “female” in it?
SQL: SELECT T1.lname ,  T1.fname FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID WHERE T2.title LIKE "%female%"

Question: What is the title of the sculpture that was created in the most recent year ?
SQL: select title from sculptures order by year desc limit 1

Question: Give me a list of names and years of paintings that were created by the artist whose first name is Mary.
SQL: SELECT T2.title ,   T2.year FROM artists AS T1 JOIN paintings AS T2 ON T1.artistID  =  T2.painterID WHERE T1.fname  =  "Mary"

Question: What is the first name of the sculptor with the greatest number of works?
SQL: SELECT T1.fname FROM artists AS T1 JOIN sculptures AS T2 ON T1.artistID  =  T2.sculptorID GROUP BY T2.sculptorID ORDER BY count(*) DESC LIMIT 1