0

漫长的夜晚,我正在努力解决这个问题。

我有一个查询,它返回具有相同结果的多行。

SELECT        apf_Members.AppsTitle, apf_Members.AppsFirstName, apf_Members.AppsLastName, vw_apf_MemStat.MemberID, vw_apf_MemStat.DNNUserID, 
                         vw_apf_MemStat.MemStat_LapsedMember, vw_apf_MemStat.MemStat_CurrentMember, vw_apf_MemStat.MemStat_Unrenewed, 
                         apf_Members.MemberID AS Member, apf_Members.PostalCompany AS Company, apf_Members.AppsFirstName AS FirstName, 
                         apf_Members.AppsLastName AS LastName, apf_Members.AppsBirthDate AS DOB, apf_Members.PostalState AS State 

FROM            apf_Members INNER JOIN
                         vw_apf_MemStat ON apf_Members.MemberID = vw_apf_MemStat.MemberID INNER JOIN
                         vw_apf_AttributesConditions ON apf_Members.MemberID = vw_apf_AttributesConditions.MemberID


WHERE        (vw_apf_MemStat.MemStat_CurrentMember <> - 1) AND (vw_apf_AttributesConditions.AttributeID = 7)
ORDER BY apf_Members.AppsLastName, State, apf_Members.MailOption

如何停止重复行?每个重复行的列似乎完全相同,因此它们肯定是重复的。

我假设它是 2x 内部连接,但我似乎无法修复它。

多谢你们,

-R

4

1 回答 1

1

三张桌子上

select memberID, count(*) 
  from table 
 group by memberID 
having count(*) > 1 
于 2013-09-23T14:21:19.863 回答