Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Cannot be bound error

Author  Topic 

jwilson911
Starting Member

2 Posts

Posted - 2015-04-04 : 04:53:38
Hi.
I have this error. I've looked at other solutions posted here and I can't find my answer.
Ay help appreciated.

Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "ephd.DepartmentID" could not be bound.


USE AdventureWorks2012;
GO

SELECT TOP(10)
eph1.BusinessEntityID,
eph1.Rate,
epdh.DepartmentID,
RANK() OVER
(PARTITION BY ephd.DepartmentID ORDER BY eph1.Rate DESC) AS RankBySalary
FROM
HumanResources.EmployeePayHistory AS eph1
INNER JOIN
HumanResources.EmployeeDepartmentHistory AS epdh
ON eph1.BusinessEntityID = epdh.BusinessEntityID
WHERE
eph1.RateChangeDate =
(SELECT
MAX(RateChangeDate)
FROM
HumanResources.EmployeePayHistory AS eph2
WHERE
eph1.BusinessEntityID = eph2.BusinessEntityID)
ORDER BY
RankBySalary,eph1.BusinessEntityID;
go

JohnRWilson

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-04 : 07:57:31
Epdh <>epdh
Go to Top of Page

jwilson911
Starting Member

2 Posts

Posted - 2015-04-07 : 03:34:33
Can't believe this.
Coming from a Sybase background this is something I would not have considered.
Thanks gbritton for this.

JohnRWilson
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2015-04-07 : 08:05:39
I don't use SSMS but would it give you a wiggle-red underline for a "typo" like that? Or could it not resolve the name at Authoring-time anyway?
Go to Top of Page
   

- Advertisement -