Re: Simple select using calculated column
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 03/03/04
- Next message: Adam Machanic: "Re: SQL and IIS"
- Previous message: Anith Sen: "Re: Simple select using calculated column"
- In reply to: Earl Teigrob: "Simple select using calculated column"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Mar 2004 18:49:16 +0100
You cannot refer to a column alias in the query (the one exception is in
ORDER BY).
So either use the same function call in the WHERE clause, or use a derived
table:
SELECT newcol
FROM
(
select dbo.function(column) as newcol
from tablename
) as der
WHERE newcol = 0
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp "Earl Teigrob" <earlt777@hotmail.com> wrote in message news:OEoRDYUAEHA.3308@TK2MSFTNGP10.phx.gbl... > I have a query like > > select dbo.function(column) as newcol > from tablename > where newcol=0 > > everything works fine without the where clause > but when I add it, I get an error that newcol is an invalid column name > > I am sure that I have done this before (quite a while ago) but can not > remember the syntax > > Thanks for the help > > Earl > >
- Next message: Adam Machanic: "Re: SQL and IIS"
- Previous message: Anith Sen: "Re: Simple select using calculated column"
- In reply to: Earl Teigrob: "Simple select using calculated column"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|