human
Schema:
artist (Artist_ID, Name, Country, Year_Join, Age)
exhibition (Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price)
exhibition_record (Exhibition_ID, Date, Attendance)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
assistant
SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
human
Show theme and year for all exhibitions with ticket prices lower than 15.
assistant
SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
human
Show theme and year for all exhibitions in an descending order of ticket price.
assistant
SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
human
How many exhibition are there in year 2005 or after?
assistant
SELECT count(*) FROM exhibition WHERE YEAR >= 2005
human
Show the theme for exhibitions with both records of an attendance below 100 and above 500.
assistant
SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
human
Return the themes, dates, and attendance for exhibitions that happened in 2004.
assistant
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 ;