February 13, 2012 at 3:02 pm
SELECT e.Pid, e.ProductName__c AS Last_Evaluation_Product__c
FROM Customers.dbo.Lead AS l INNER JOIN
(SELECT MAX(LeadId__c) AS Pid
FROM Customers.dbo.Evaluation__c
GROUP BY LeadId__c) AS e ON l.Id COLLATE SQL_Latin1_General_CP1_CI_AS = e.Pid
WHERE (l.IsDeleted = 0)
I need to get the ProductName__c from the Customers.dbo.Evaluation__c table but I'm getting an error stating invalid column name 'ProductName__c' , but I know it's the correct column name. I'm sure it's something simple, but I don't see it.
February 13, 2012 at 3:14 pm
What is e? I do not see it specified. I assume you want to alias your subquery. If that is the case your subquery is not returning that column.
EDIT:Saw e. However, you have to return all columns needed in your main query within that subquery if you are going to reference them
Jared
CE - Microsoft
February 13, 2012 at 3:17 pm
You reference e.ProductName__c but this column is not part of your subquery.
Either the column is included in the subquery or should be referenced based on Customers.dbo.Lead (l.ProductName__c).
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply