使用电子邮件和电话对客户进行实体解析
我有一个包含 ID、全名、电子邮件和电话的客户表
| id | full_name | email | phone |
| -- | -------------- | -------------------------- | ------------- |
| 1 | namita.robin | [email protected] | +135698887445 |
| 2 | alfred.buka | [email protected] | +236588547811 |
| 3 | karim.tazi | [email protected] | +212661845794 |
| 4 | | [email protected] | +135698887445 |
| 5 | cheri | [email protected] | +135698748788 |
| 6 | rim.rim | [email protected] | +245881148787 |
,我想对至少具有相同电子邮件或电话的客户进行分组。 此示例的期望输出为:
| id | full_name | email | phone | master_id |
| -- | -------------- | -------------------------- | ------------- | --------- |
| 1 | namita.robin | [email protected] | +135698887445 | 1 |
| 2 | alfred.buka | [email protected] | +236588547811 | 2 |
| 3 | karim.tazi | [email protected] | +212661845794 | 3 |
| 4 | | [email protected] | +135698887445 | 1 |
| 5 | cheri | [email protected] | +135698748788 | 1 |
| 6 | rim.rim | [email protected] | +245881148787 | 2 |
I have a customers table with id, full_name, email, and phone
| id | full_name | email | phone |
| -- | -------------- | -------------------------- | ------------- |
| 1 | namita.robin | [email protected] | +135698887445 |
| 2 | alfred.buka | [email protected] | +236588547811 |
| 3 | karim.tazi | [email protected] | +212661845794 |
| 4 | | [email protected] | +135698887445 |
| 5 | cheri | [email protected] | +135698748788 |
| 6 | rim.rim | [email protected] | +245881148787 |
and I want to group customers that have at least an email or phone that is the same.
desired output for this example would be:
| id | full_name | email | phone | master_id |
| -- | -------------- | -------------------------- | ------------- | --------- |
| 1 | namita.robin | [email protected] | +135698887445 | 1 |
| 2 | alfred.buka | [email protected] | +236588547811 | 2 |
| 3 | karim.tazi | [email protected] | +212661845794 | 3 |
| 4 | | [email protected] | +135698887445 | 1 |
| 5 | cheri | [email protected] | +135698748788 | 1 |
| 6 | rim.rim | [email protected] | +245881148787 | 2 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用dense_rank() 为相同的电子邮件类型获取相同的id 值。仅从电子邮件列中获取电子邮件类型并按该类型排序。
You can use dense_rank() to get the same id value for the same email type. Get only email type from the email column and order by that.