Database: performance_attendance

CREATE TABLE "member" (
    "Member_ID" text,
    "Name" text,
    "Nationality" text,
    "Role" text,
    PRIMARY KEY ("Member_ID")
);
CREATE TABLE "performance" (
    "Performance_ID" real,
    "Date" text,
    "Host" text,
    "Location" text,
    "Attendance" int,
    PRIMARY KEY ("Performance_ID")
);
CREATE TABLE "member_attendance" (
    "Member_ID" int,
    "Performance_ID" int,
    "Num_of_Pieces" int,
    PRIMARY KEY ("Member_ID","Performance_ID"),
    FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID"),
    FOREIGN KEY ("Performance_ID") REFERENCES `performance`("Performance_ID")
);

Question: How many performances are there?
SQL: SELECT count(*) FROM performance

Question: List the hosts of performances in ascending order of attendance.
SQL: SELECT HOST FROM performance ORDER BY Attendance ASC

Question: What are the dates and locations of performances?
SQL: SELECT Date ,  LOCATION FROM performance

Question: Show the attendances of the performances at location "TD Garden" or "Bell Centre"
SQL: SELECT Attendance FROM performance WHERE LOCATION  =  "TD Garden" OR LOCATION  =  "Bell Centre"

Question: What is the average number of attendees for performances?
SQL: SELECT avg(Attendance) FROM performance

Question: What is the date of the performance with the highest number of attendees?
SQL: SELECT Date FROM performance ORDER BY Attendance DESC LIMIT 1

Question: Show different locations and the number of performances at each location.
SQL: SELECT LOCATION ,  COUNT(*) FROM performance GROUP BY LOCATION

Question: Show the most common location of performances.
SQL: SELECT LOCATION FROM performance GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1

Question: Show the locations that have at least two performances.
SQL: SELECT LOCATION FROM performance GROUP BY LOCATION HAVING COUNT(*)  >=  2

Question: Show the locations that have both performances with more than 2000 attendees and performances with less than 1000 attendees.
SQL: SELECT LOCATION FROM performance WHERE Attendance  >  2000 INTERSECT SELECT LOCATION FROM performance WHERE Attendance  <  1000

Question: Show the names of members and the location of the performances they attended.
SQL: SELECT T2.Name ,  T3.Location FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID  =  T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID  =  T3.Performance_ID

Question: Show the names of members and the location of performances they attended in ascending alphabetical order of their names.
SQL: SELECT T2.Name ,  T3.Location FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID  =  T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID  =  T3.Performance_ID ORDER BY T2.Name ASC

Question: Show the dates of performances with attending members whose roles are "Violin".
SQL: SELECT T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID  =  T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID  =  T3.Performance_ID WHERE T2.Role  =  "Violin"

Question: Show the names of members and the dates of performances they attended in descending order of attendance of the performances.
SQL: SELECT T2.Name ,  T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID  =  T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID  =  T3.Performance_ID ORDER BY T3.Attendance DESC

Question: List the names of members who did not attend any performance.
SQL: SELECT Name FROM member WHERE Member_ID NOT IN (SELECT Member_ID FROM member_attendance)