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 2008 Forums
 Transact-SQL (2008)
 why wont this join?

Author  Topic 

kcarbone1970
Yak Posting Veteran

52 Posts

Posted - 2015-03-31 : 12:49:52
I keep getting invalid column ?? abc




SELECT CAST(c.CountyCode AS VARCHAR(2)) + CAST(c.DistrictCode AS VARCHAR(10)) + CAST(c.SchoolCode AS VARCHAR(12)) AS abc

FROM CAHSEE2014new c INNER JOIN CDS a ON abc = a.CDSCODE


Cartesian Yak

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-31 : 13:19:03
You can't use an alias until the order by clause. here's one easy way around it.


select abc
from CAHSEE2014new c
cross apply
(
select CAST(c.CountryCode AS VARCHAR(2)) + CAST(c.DistrictCode AS VARCHAR(10)) + CAST(c.SchoolCode AS VARCHAR(12)) AS abc
) _
INNER JOIN CDS a ON abc = a.CDSCODE
Go to Top of Page

kcarbone1970
Yak Posting Veteran

52 Posts

Posted - 2015-04-01 : 13:39:42
Thank You!

Cartesian Yak
Go to Top of Page
   

- Advertisement -