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
Show member names with a registered branch?
assistant
SELECT name FROM member WHERE member_id IN ( SELECT member_id FROM membership_register_branch );
human
Show member names without any registered branch?
assistant
SELECT name FROM member WHERE member_id NOT IN ( SELECT member_id FROM membership_register_branch );
human
What is the total number of branches?
assistant
SELECT COUNT( distinct branch_id ) FROM membership_register_branch ;