human
Schema:
member (Member_ID, Card_Number, Name, Hometown, Level)
branch (Branch_ID, Name, Open_year, Address_road, City, membership_amount)
membership_register_branch (Member_ID, Branch_ID, Register_Year)
purchase (Member_ID, Branch_ID, Year, Total_pounds)
Please answer with SQL.
assistant
Sure, I understand.
human
how many purchases did each member make?
assistant
SELECT T1.member_id , COUNT( * ) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id GROUP by T1.member_id;
human
how many purchases did members with level 5 make?
assistant
SELECT COUNT( * ) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 5 ;