SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using a label from AS in a WHERE clause
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DaveBF
Yak Posting Veteran

68 Posts

Posted - 08/22/2012 :  07:59:23  Show Profile  Reply with Quote
I'm trying to use the label defined using AS in a WHERE clause. Is there any way to do that? This says "Invalid Column Name 'EmpStatus'".
This is a simplified version of the query.

select
case when New=1 then 'New Employee' when New=0 then 'Old Employee'
else 'Employee' end As EmpStatus
from Person

where EmpStatus like '%'

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 08/22/2012 :  08:13:26  Show Profile  Reply with Quote
select *
from
(
select case when New=1 then 'New Employee' 
            when New=0 then 'Old Employee'
            else 'Employee' end As EmpStatus
from Person
) as D
where EmpStatus like '%'



KH
Time is always against us

Go to Top of Page

DaveBF
Yak Posting Veteran

68 Posts

Posted - 08/22/2012 :  08:38:58  Show Profile  Reply with Quote
Thank you. That worked. I wouldn't have figured this out myself.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000