error – The multi-part identifier “Grant.EmpID” could not be bound.
query –
select emp.EmpID,
COUNT(*) as CountRecords,
COUNT(GrantName) AS CountValues
From Employee as emp full join [Grant] as gr
on emp.EmpID = [Grant].EmpID
-- This is the cause for the error ! Change it to gr.EmpID
group by emp.EmpID
Why does this error occur ? Can’t I call a person by real name and also by nickname ?
You’re aliasing
[Grant]. In other words, you’re stating that from here on out,[Grant]will be referred to asgr.Use the
ALIASin theGROUP BYclause, not the tableName.here’s the SQL Order of Operation