Help with query

  • 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.

  • 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

  • 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).



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply