Click here to Skip to main content
15,887,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai friends,
I tried one day about the below query but i didn't get the out put..

Query is:

SQL
select distinct L.LeadBudget,L.CompanyName,L.LeadTitle,L.Status,

E.Name as OwnerName,E.Name as 

CreatedUser

 from Leads L,Employee E where L.LeadId='2' 

 and E.EmployeeId=L.LeadOwner and E.EmployeeId=L.CreatedUserId



In The above query i want to get E.Name as OwnerName and E.Name as CreatedUser

from a single Employee tables)..where E.EmployeeId=L.LeadOwner and

E.EmployeeId=L.CreatedUserId

if i execute with out OwnerName or Created User i am getting the data..but i want to get both the names..

Please help me in this regard..

Thanks in advance
Posted
Updated 8-Feb-13 17:49pm
v3

Try this
SQL
select distinct L.LeadBudget,L.CompanyName,L.LeadTitle,L.Status,

E.Name as OwnerName,E.Name as

CreatedUser

 from Leads L join Employee E ON E.EmployeeId=L.LeadOwner and E.EmployeeId=L.CreatedUserId where L.LeadId='2'
 
Share this answer
 
Comments
.net333 8-Feb-13 7:44am    
Thank you gagan..but it's not worked for me
gagan sawaliya 13-Feb-13 4:40am    
Your question was not according to your answer. Plz correct your question
SQL
select distinct L.LeadBudget,L.CompanyName,L.LeadTitle,L.Status,

E.[Name] as [OwnerName],E.[Name] as

[CreatedUser]

 from Leads L join Employee E ON E.EmployeeId=L.LeadOwner and E.EmployeeId=L.CreatedUserId where L.LeadId='2'
 
Share this answer
 
finally i got the output...

SQL
SELECT l.LeadBudget, l.CompanyName, l.LeadTitle, l.Status, leadEmp.Name As OwnerName, createdEmp.Name As CreatedUser
FROM Leads l
     INNER JOIN Employee leadEmp ON(l.LeadOwner = leadEmp.EmployeeId)
     INNER JOIN Employee createdEmp ON(l.CreatedUserId= createdEmp.EmployeeId)
WHERE l.LeadId='2'
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900