Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
p.shaw3@ukonline.co.uk
Posting Yak Master
103 Posts |
Posted - 2005-10-22 : 13:43:07
|
| I have the following join in my query as a stored proc in my SQL Server Database:SELECT Distinct AMMCall.dbo.AMM_AGENT_TEAM_FACT.KeyID as 'Agent ID', AMMCall.dbo.AC_GUEST_AGENTDETAILS.FirstName as'Agent Firstname', AMMCall.dbo.AC_GUEST_AGENTDETAILS.surname as'Agent Surname'FROM AMMCall.dbo.AMM_AGENT_TEAM_FACTINNER JOIN AMMCall.dbo.AC_GUEST_AGENTDETAILS ON AMMCall.dbo.AMM_AGENT_TEAM_FACT.KeyID =AMMCall.dbo.AC_GUEST_AGENTDETAILS.KeyIDleft outer join LSLL.dbo.Timesheets ON AMMCall.dbo.AMM_AGENT_TEAM_FACT.KeyID = LSLL.dbo.Timesheets.AgentID AND LSLL.dbo.Timesheets.[Date] = convert(varchar, DATEADD(d,-1,GETDATE()),103) where LSLL.dbo.Timesheets.AgentID is NULLORDER by AMMCall.dbo.AC_GUEST_AGENTDETAILS.FirstName ASCThis query works fine and produces the correct results but my problem starts when I try to add another inner join to pull records from another table. I have tried various places to insert the new join but receive errors. Can anyone help please? |
|
|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-10-22 : 16:01:09
|
| Please post what you are trying to add and explain what you are trying to do. Schema and Sample data would be very helpful as well. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-10-22 : 16:03:56
|
FROM AMMCall.dbo.AMM_AGENT_TEAM_FACTINNER JOIN AMMCall.dbo.AC_GUEST_AGENTDETAILS ON AMMCall.dbo.AMM_AGENT_TEAM_FACT.KeyID =AMMCall.dbo.AC_GUEST_AGENTDETAILS.KeyIDjoin NewTable t1 on t1.joinColumn = otherJoinTable.joinColumnleft outer join LSLL.dbo.Timesheets Go with the flow & have fun! Else fight the flow |
 |
|
|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-10-22 : 16:18:56
|
| Just make sure you aren't joining with a column from your outer join table (LSLL.dbo.Timesheets), as that will always return zero results due to your where clause. |
 |
|
|
|
|
|