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
 Development Tools
 ASP.NET
 SELECT QUERY WITH EXPESSION COLUMN IN WHERE CLAUSE

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-03-23 : 08:37:07
I HAVE WRITTEN THE QUERY
SELECT DISTINCT LEFT(Location_ID, 2)AS STATE,RIGHT(Location_ID, 3)AS LOCATION
FROM LOCATION
WHERE STATE LIKE 'AK'

BUT I AM GETTING ERROR
Invalid column name 'STATE'.

HOW TO RESOLVE THIS?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-23 : 08:40:17
You have what?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81100

SELECT DISTINCT LEFT(Location_ID, 2)AS STATE,RIGHT(Location_ID, 3)AS LOCATION
FROM LOCATION
WHERE Location_ID LIKE 'AK%'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-03-23 : 08:47:04
Thank u Peter ,

Query is working fine
quote:
Originally posted by Peso

You have what?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81100

SELECT DISTINCT LEFT(Location_ID, 2)AS STATE,RIGHT(Location_ID, 3)AS LOCATION
FROM LOCATION
WHERE Location_ID LIKE 'AK%'


Peter Larsson
Helsingborg, Sweden

Go to Top of Page
   

- Advertisement -