gpt4 book ai didi

sql - 查找与多个州相关联的邮政编码

转载 作者:行者123 更新时间:2023-12-02 05:21:53 25 4
gpt4 key购买 nike

我有一个数据库,其中包含 5 位邮政编码(即 10001)和匹配的州缩写(即 NJ、NY、CA)。我发现一些邮政编码有多个州(即 10001 = NJ 和 10001 = NY),这是错误的。

   zip         State
10001 NY
10001 NJ
10001 NY
10001 NY
... ...

每个州可以有多个邮政编码,但每个邮政编码只能有一个州。

我想找到所有错误,但似乎无法编写查询来这样做。

有什么建议?

最佳答案

只是指出显而易见的:

Because ZIP codes are intended for efficient postal delivery, there are unusual cases where a ZIP code crosses state boundaries, such as a military facility spanning multiple states or remote areas of one state most easily serviced from an adjacent state. For example ZIP code 42223 spans Christian KY and Montgomery TN, and ZIP code 97635 spans Lake OR and Modoc CA.

http://en.wikipedia.org/wiki/ZIP_code



谨慎对待规范数据,并始终相信提供真实数据的人。

在这种情况下,0 代表 NJ,所以 10001对于 NJ 来说是错误的,但是 00001对 NJ 来说是准确的,而 1 对 NY 来说是准确的,所以 00001对纽约来说是错误的,但是 10001对纽约来说是准确的。另见 http://en.wikipedia.org/wiki/List_of_ZIP_code_prefixes

另外值得注意的是,通过上一个链接中的 1000 个邮政编码,您可以准确地确定哪些邮政编码超出了它们应该处于的范围/状态...

关于sql - 查找与多个州相关联的邮政编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12450960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com