如何从同一来源查找具有多个不同 SICCode 的 PolicyNumber table
How to find PolicyNumber that have more than one DIFFERENT SICCode from the same source table
我有 table,PolicyNumber
和 SICCode
。
通常每个 PolicyNumber
只有一个唯一的 SICCode
。但我想检查一下,以确保数据正确。
我该怎么做?
下面的查询给出了每个 PolicyNumber
的 SICCode
的数量,但这不是我需要的。我想确定什么 PolicyNumber
(如果有的话)有不止一个不同的 SICCodes
.
select PolicyNumber,
count(SICCode) as count
from PlazaInsuranceWPDataSet
group by PolicyNumber
having count(SICCode)>1
使用COUNT(DISTINCT SICCode)
:
Select PolicyNumber,
Count(Distinct SICCode) As count
From PlazaInsuranceWPDataSet
Group By PolicyNumber
Having Count(Distinct SICCode) > 1;
我有 table,PolicyNumber
和 SICCode
。
通常每个 PolicyNumber
只有一个唯一的 SICCode
。但我想检查一下,以确保数据正确。
我该怎么做?
下面的查询给出了每个 PolicyNumber
的 SICCode
的数量,但这不是我需要的。我想确定什么 PolicyNumber
(如果有的话)有不止一个不同的 SICCodes
.
select PolicyNumber,
count(SICCode) as count
from PlazaInsuranceWPDataSet
group by PolicyNumber
having count(SICCode)>1
使用COUNT(DISTINCT SICCode)
:
Select PolicyNumber,
Count(Distinct SICCode) As count
From PlazaInsuranceWPDataSet
Group By PolicyNumber
Having Count(Distinct SICCode) > 1;