human
Schema:
accounts (custid, name)
savings (custid, balance)
checking (custid, balance)
Please answer with SQL.
assistant
Sure, I understand.
human
Show all the names for each account.
assistant
SELECT name FROM accounts;
human
What are the unique set of names?
assistant
SELECT DISTINCT name FROM accounts;
human
How many savings accounts under each of these names?
assistant
SELECT COUNT( * ) , T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid GROUP BY T1.name ;