Solved

The correlation name 'ej' is specified multiple times in a FROM clause

Posted on 2008-10-09
2
1,552 Views
Last Modified: 2010-05-18
Im trying to do this but keep getting the error shown in the title

Not sure what im missing
select DISTINCT

e.EmployeeID,

es.EmployeeStatus AS Status,

e.EmployeeDescNoID AS Emp_Name,

e.WindowsUserName AS LoginID,

e.DisplayEmployeeID AS UserID,

e.ExtNoUD AS Extension,

e.FFWMobileUD AS FFWMobile,

e.WorkEmail AS Email,

-- profitcentre

-- department

e.EliteNoUD AS SectionNumber,

e.SecretaryNameUD AS Secretary,

e.LocationUD AS Location,

ej.PostID AS Position
 

FROM [Cascade].dbo.Employee e
 

JOIN [Cascade].dbo.EmployeeJobs ej

  ON e.EmployeeID = ej.EmployeeID
 

JOIN [Cascade].dbo.Employee_Status es

  ON e.EmployeeID = es.EmployeeID
 

LEFT OUTER JOIN (select t1.JobTitle, t1.EmployeeID

                   from [Cascade].dbo.EmployeeJobs t1 

                   join (select employeeId, min(Sequence) as sequence 

                           from [Cascade].dbo.EmployeeJobs 

                          group by employeeID

                        ) t2

                     on t1.employeeid = t2.employeeID 

                    and t1.Sequence  = t2.Sequence

                 ) ej

  ON e.EmployeeID = ej.EmployeeID
 

WHERE es.EmployeeStatus = 'Current'

Open in new window

0
Comment
Question by:mooriginal
2 Comments
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 22679394
you are using same alias name ej in two places,
change one of them to a different name like ej1

select DISTINCT

e.EmployeeID,

es.EmployeeStatus AS Status,

e.EmployeeDescNoID AS Emp_Name,

e.WindowsUserName AS LoginID,

e.DisplayEmployeeID AS UserID,

e.ExtNoUD AS Extension,

e.FFWMobileUD AS FFWMobile,

e.WorkEmail AS Email,

-- profitcentre

-- department

e.EliteNoUD AS SectionNumber,

e.SecretaryNameUD AS Secretary,

e.LocationUD AS Location,

ej.PostID AS Position

 

FROM [Cascade].dbo.Employee e

 

JOIN [Cascade].dbo.EmployeeJobs ej

  ON e.EmployeeID = ej.EmployeeID

 

JOIN [Cascade].dbo.Employee_Status es

  ON e.EmployeeID = es.EmployeeID

 

LEFT OUTER JOIN (select t1.JobTitle, t1.EmployeeID

                   from [Cascade].dbo.EmployeeJobs t1 

                   join (select employeeId, min(Sequence) as sequence 

                           from [Cascade].dbo.EmployeeJobs 

                          group by employeeID

                        ) t2

                     on t1.employeeid = t2.employeeID 

                    and t1.Sequence  = t2.Sequence

                 ) ej1

  ON e.EmployeeID = ej1.EmployeeID

 

WHERE es.EmployeeStatus = 'Current'

Open in new window

0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22679503
appari: is correct
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to base a filter depending on fields contents? 15 49
Need to update TableA to TableB 6 34
Azure SQL Insert not working suddenly 11 22
Sql Query with datetime 3 12
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now