【发布时间】:2021-08-12 13:46:32
【问题描述】:
我是 sql 的超级新手,不知道是否有可能,但是 我想从以下 SELECT DISTINCT 输出中选择 RANK 的值并将其插入到名为 Country 的表的第一列中。
然后选择 address_country 列并将其插入“Country”表的第二列,但我不知道该怎么做。我真的很感激任何帮助。谢谢!
INSERT INTO Country
SELECT country_code from
(SELECT DISTINCT address_country,
RANK() over (order by address_country asc) AS country_code
FROM CUSTOMER_INFO Where CUSTOMER_INFO.address_country is not NULL),
SELECT address_country from
(SELECT DISTINCT address_country,
RANK() over (order by adr_country asc) AS country_code
FROM CUSTOMER_INFO
Where CUSTOMER_INFO.address_country is not NULL);
【问题讨论】:
标签: mysql sql sql-insert rank distinct-values