Syed Gillani
Syed Gillani

Reputation: 21

How Do I correct the query Using Alias

  Select Top 100

   A.Mnumber AS ContractNumber,
   B.Payor_Parent_Code,
   C.Payor_Parent_Name,
   B.Payor_Code,
   D.Payor_Name,
   E.Payor_Plan_Code,
   E.Payor_Plan_Name


from A

    left join B ON  A.[Payor_Plan_Code]=B.[Payor_Plan_Code]
    INNER JOIN  C ON B.[Payor_Parent_Code]=C.[Payor_Parent_Code]
    INNER JOIN D ON A.Payor_Code=D.Payor_Code
    INNER JOIN  E ON A.[Payor_Plan_Code]=E.[Payor_Plan_Code]

    WHERE NOT Payor_Parent_Name  = 'OTHER'       

using this query i am getting an error Invalid object name 'A'. I would be thankful

Upvotes: 1

Views: 63

Answers (1)

S3S
S3S

Reputation: 25112

The issue is with A.Mnumber AS ContractNumber. Here you are referencing a column Mnumber from a an object A seemingly doesn't exist. This means you don't have a table or view named A but likely meant SomeTable as A based on the rest of your code.

Aaron Bertrand: Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)

For the tables you have, you should choose better aliases like payorPlan, payorParent, or something meaningful.

Upvotes: 1

Related Questions