1

我单击 REFRESH FIELDS 查询共享数据集,并收到此错误:

在此处输入图像描述

这是我的查询:

Select
            p.AgeCodePL ,
p.BirthDate ,
p.CommunityIDY  ,
p.Company   ,
p.CreatedbyUser ,
p.DateCreated   ,
p.DateExpired   ,
p.DateUpdated   ,
p.Department    ,
p.EthnicityFK   ,
p.FirstName firstFirstName,
p.GenderUL  ,
p.LastName  ,
p.MaritalStatusUL   ,
p.MiddleName    ,
p.NickName  ,
p.PeopleIDY ,
p.PrefixUL  ,
p.RaceUL    ,
p.ReligionUL    ,
p.Salutation    ,
p.SpouseName    ,
p.SSN   ,
p.SuffixUL  ,
p.Title ,
p.UpdatedbyUser ,
r.ACT_ID    ,
r.HEA_ID    ,
r.INT_ID    ,
r.LIF_ID    ,
r.NetworkSet    ,
r.PER_ID    ,
r.RES_Active    ,
r.RES_Bio   ,
r.RES_BioUpdate ,
r.RES_BioUpdateBy   ,
r.RES_CommunityIDY  ,
r.RES_CurrentUnitNumber ,
r.RES_DateStarted   ,
r.RES_DiscNotes1    ,
r.RES_DiscNotes2    ,
r.RES_DiscNotes3    ,
r.RES_DiscNotes4    ,
r.RES_DiscNotes5    ,
r.RES_ExpiredDate   ,
r.RES_ExpiredUser   ,
r.RES_FinishedDate  ,
r.RES_HasImage  ,
r.RES_LastUserUpdated   ,
r.RES_LobbyBio  ,
r.RES_LobbyBioUpdate    ,
r.RES_LobbyBioUpdateBy  ,
r.RES_NoPart    ,
r.RES_PeopleIDY ,
r.RES_PhyMoveInDate ,
r.RES_TasksSet  ,
r.RES_UpdatedImage  ,
r.STA_ID    ,
r.STA_Type  ,
r.TES_ID    ,
rr.CommunityIDY ,
rr.CurrentUnitNumber    ,
rr.Gender   ,
rr.MainBirthDate    ,
rr.MainFirstName    ,
rr.MainLastName ,
rr.MainPeopleIDY    ,
rr.Name ,
rr.ProspectIDY  ,
s.RES_ID    ,
s.STA_Active    ,
s.STA_CreatedOn ,
s.STA_DateUpdated   ,
s.STA_Details   ,
s.STA_EditedDate    ,
s.STA_EditedUser    ,
s.STA_ID    ,
s.STA_Reason    ,
s.STA_Solution  ,
s.STA_Type  ,
s.STA_User  ,
u.PRO_ID    ,
u.STU_ID    ,
u.TEA_ID    ,
u.USR_AboutMe   ,
u.USR_Active    ,
u.USR_AllComm   ,
u.USR_Bday  ,
u.USR_BdayDay   ,
u.USR_CellPhone ,
u.USR_CommLocation  ,
u.USR_CommunityIDY  ,
u.USR_ContactFor    ,
u.USR_DirectPhone   ,
u.USR_Email ,
u.USR_EntAdmin  ,
u.USR_FavBooks  ,
u.USR_FavMovies ,
u.USR_FavPart   ,
u.USR_FavQuotes ,
u.USR_Fax   ,
u.USR_First ,
u.USR_Goals ,
u.USR_HasImage  ,
u.USR_HomeTown  ,
u.USR_ID    ,
u.USR_Interests ,
u.USR_INTL_Password ,
u.USR_INTL_UserName ,
u.USR_IsSales   ,
u.USR_JoinedKisco   ,
u.USR_Last  ,
u.USR_LastLogin ,
u.USR_LastProUpdate ,
u.USR_Name  ,
u.USR_OtherTeams    ,
u.USR_Password  ,
u.USR_PlacesBeen    ,
u.USR_REPS_Password ,
u.USR_REPS_UserIDY  ,
u.USR_REPS_UserName ,
u.USR_Role  ,
u.USR_RoleDescrip   

            from
            Status s
            Inner Join Residents r
            ON r.RES_ID = s.RES_ID
            Left Join REPSResidents rr
            ON rr.MainPeopleIDY = r.RES_PeopleIDY
            Inner Join Associate u
            ON s.STA_User = u.USR_ID
            Inner Join KSLSQL1.[RPS-201065-000].dbo.people p
            ON r.RES_PeopleIDY = p.PeopleIDY
            Where
            rr.CommunityIDY in (@Community)
            and (s.STA_Reason is not null and s.STA_Reason <> '')
and s.STA_Active = 1
and s.STA_DateUpdated between @BegDate and dateadd(d,1,@EndDate)
Order by
s.STA_DateUpdated DESC

我究竟做错了什么?

4

1 回答 1

30

问题是因为您的查询中有两列名称完全相同

r.RES_ID    ,
s.RES_ID    ,

列必须具有不同的名称。要么给它们一个别名以使它们不同,要么删除其中一个,因为它们将根据您的加入具有相同的值。

于 2013-06-25T18:24:44.023 回答