November 26, 2002 at 2:31 am
Hi,
here is my query:
select Name + Surname as Fullname where Fullname > "Paul" order by Fullname
this query is wrong, the right query is:
select Name + Surname as Fullname where Name + Surname > "Paul" order by Fullname.
My question is:
"where" clause don't accept alias field name while "order by" clause yes; it's right ?
Thanks, anakin
November 26, 2002 at 3:08 am
Yep thats right its a really arse sometimes.
If you have a really complex expression put it in a derived table i.e
select fullname
from (
select Name + Surname as Fullname ) as a
where Fullname > 'Paul'
order by Fullname
Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons
November 26, 2002 at 3:27 am
I try it in query analizer but raise sintax error, where is the where clause ?
Can you rewrite the sample query ?
anakin
November 26, 2002 at 3:56 am
Seems find except for table name
i.e.
select fullname
from (select Name + Surname as Fullname from tablea) as a
where Fullname > 'Paul'
order by Fullname
Far away is close at hand in the images of elsewhere.
Anon.
November 26, 2002 at 6:28 am
What version of SQL are you using?
Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply