Database: theme_gallery

Question: How many artists do we have?
SQL: SELECT count(*) FROM artist

Question: Show all artist name, age, and country ordered by the year they joined.
SQL: SELECT name ,  age ,  country FROM artist ORDER BY Year_Join

Question: What are all distinct country for artists?
SQL: SELECT DISTINCT country FROM artist

Question: Show all artist names and the year joined who are not from United States.
SQL: SELECT name ,  year_join FROM artist WHERE country != 'United States'

Question: How many artists are above age 46 and joined after 1990?
SQL: SELECT count(*) FROM artist WHERE age  >  46 AND year_join  >  1990

Question: What is the average and minimum age of all artists from United States.
SQL: SELECT avg(age) ,  min(age) FROM artist WHERE country  =  'United States'

Question: What is the name of the artist who joined latest?
SQL: SELECT name FROM artist ORDER BY year_join DESC LIMIT 1

Question: How many exhibition are there in year 2005 or after?
SQL: SELECT count(*) FROM exhibition WHERE YEAR  >=  2005

Question: Show theme and year for all exhibitions with ticket prices lower than 15.
SQL: SELECT theme ,  YEAR FROM exhibition WHERE ticket_price  <  15

Question: Show all artist names and the number of exhibitions for each artist.
SQL: SELECT T2.name ,  count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id  =  T2.artist_id GROUP BY T1.artist_id

Question: What is the name and country for the artist with most number of exhibitions?
SQL: SELECT T2.name , T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id  =  T2.artist_id GROUP BY T1.artist_id ORDER BY count(*) DESC LIMIT 1

Question: Show names for artists without any exhibition.
SQL: SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)

Question: What is the theme and artist name for the exhibition with a ticket price higher than the average?
SQL: SELECT T1.theme ,  T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id  =  T2.artist_id WHERE T1.ticket_price  >  (SELECT avg(ticket_price) FROM exhibition)

Question: Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
SQL: SELECT avg(ticket_price) ,  min(ticket_price) ,  max(ticket_price) FROM exhibition WHERE YEAR  <  2009

Question: Show theme and year for all exhibitions in a descending order of ticket price.
SQL: SELECT theme ,  YEAR FROM exhibition ORDER BY ticket_price DESC

Question: What is the theme, date, and attendance for the exhibition in year 2004?
SQL: SELECT T2.theme ,  T1.date ,  T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id  =  T2.exhibition_id WHERE T2.year  =  2004

Question: Show all artist names who didn't have an exhibition in 2004.
SQL: SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id  =  T2.artist_id WHERE T1.year  =  2004