2013-06-25 32 views
-1

我對REFRESH FIELDS點擊我的查詢共享數據集,並收到此錯誤:無法創建字段列表的查詢

enter image description here

,這裏是我的查詢:

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 

我做錯了什麼?

+0

如果你只是運行'select * from rewSQL1。[RPS-000] .dbo.people'你會得到一個錯誤嗎? – xQbert

+0

是的,工作 –

回答

23

的問題是,因爲你在你的查詢有two columns with the exact same name

r.RES_ID , 
s.RES_ID , 

的列必須有不同的名稱。要麼給他們一個別名,以使他們不同或刪除其中的一個,因爲他們將有基於您的連接相同的值。

+0

感謝ive更新,但仍然是相同的問題 –

+3

@АртёмЦарионов你有兩個'CommunityIDY'列。您不能有任何具有相同名稱的列 – Taryn

+0

翻譯。寫給我。 – Zane