考虑表1的以下数据
CustomerId Division email
C1 D1 [email protected]
C1 D2 [email protected]
C2 D1 [email protected]
C2 D2 [email protected]
我需要编写sql才能将电子邮件列数据移动到下面的Table2中结果应该如下考虑表2中包含以下数据(CustomerId不是主键)
CustomerId email Type
C1 [email protected]
C2 [email protected]
请有人可以为此提供sql,并且Table2中的值应该始终是唯一的customerId?
您似乎想要:
select distinct customerid, email, null as type
from table1;