我有一张桌子customers
。如何仅为电子邮件列中的不同值选择ID?
+----+------------------+
| Id | Email |
+----+------------------+
| 1 | sergiy@gmail.com |
| 2 | bob@gmail.com |
| 3 | anre@gmail.com |
| 4 | sergiy@gmail.com |
| 5 | antony@gmail.com |
+----+------------------+
结果将是:
[1,2,3,5]
到目前为止,我已经尝试过了:
select distinct id, email from customers group by id;
答案 0 :(得分:3)
select min(id) from Customers group by email;