Solved

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

Posted on 2008-10-09
2
1,533 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 121
PL/SQL query 14 51
Test a query 23 18
How toselect unique values 3 10
In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

746 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

12 Experts available now in Live!

Get 1:1 Help Now