返回与另一个表不匹配的SQL行

时间:2021-04-09 09:29:23

I have a table with 3 columns:

我有一个包含3列的表格:

  1. AccountID
  2. HH_Num
  3. RepCode

I need a way to see the rows where any HH_Num is the same, but the RepCode is different.

我需要一种方法来查看任何HH_Num相同的行,但RepCode是不同的。

Example:

Account ID  HH_Num    RepCode
1234        10000     SS01
1235        10000     SS01
1236        10000     SS01
1237        10000     PO45
1238        50000     UY01
1239        50000     UY01
1241        50000     UY75

So my query need to return the rows wherethe HH_Num = the same as other data, but RepCode does NOT match..... Any thoughts????? Hint: My query should return 2 results since they have the same HH_Num but different RepCodes?????

所以我的查询需要返回HH_Num =与其他数据相同的行,但RepCode不匹配.....任何想法?????提示:我的查询应返回2个结果,因为它们具有相同的HH_Num但不同的RepCodes ?????

1 个解决方案

#1


0  

Try this:

select DISTINCT HH_Num, RefCode 
from yourtable

#1


0  

Try this:

select DISTINCT HH_Num, RefCode 
from yourtable