【发布时间】:2023-01-25 19:27:57
【问题描述】:
假设我有 addresses 和 country_codes 表。addresses表有不正确的country_code值,我想根据地址用country_codes表中的country_code替换它们。
如何在雪花中做到这一点?
请注意,address 列中可能包含国家名称或国家代码。
表:
+--------------+-----------------------------------+
| country_code | address |
+--------------+-----------------------------------+
| US | 1145 Oakmound Drive, US |
| W | 4733 Pallet Street, United States |
| F | Rua Wanda Carnio 190, Brazil |
| 22 | Via delle Viole 137, Italy |
| 50 | 7 Essex Rd, GB |
+--------------+-----------------------------------+
+--------------+----------------+
| country_code | country |
+--------------+----------------+
| GB | United Kingdom |
| BR | Brazil |
| IT | Italy |
| US | United States |
+--------------+----------------+
期望的输出:
+--------------+-----------------------------------+
| country_code | address |
+--------------+-----------------------------------+
| US | 1145 Oakmound Drive, US |
| US | 4733 Pallet Street, United States |
| BR | Rua Wanda Carnio 190, Brazil |
| IT | Via delle Viole 137, Italy |
| GB | 7 Essex Rd, GB |
+--------------+-----------------------------------+
【问题讨论】:
标签: sql snowflake-cloud-data-platform