August 8, 2008 at 4:17 am
This has been a ongoing gripe of mine that until now I have been able to get around. The problem is not being able to reference calculated fields in other fields. Eg./
SELECT 1+2 as Three, Three+3 AS Six
Is there way to get the above to work? (The issue being the second field has no knowledge of what Three is.)
August 8, 2008 at 4:44 am
You may use derived tables:
SELECT Three, Three+3 AS Six
FROM (
SELECT 1+2 as Three
) DT
_____________
Code for TallyGenerator
August 8, 2008 at 6:23 am
Paul:
The "short" answer to your question is that MS SQL Server does not presently support that kind of alias. A work around such as the previous post is required or you might simply want to in-line compute the expression with something like:
select 1+2 as Three, (1+2)+2 as Six
August 8, 2008 at 6:26 am
Thanks for the answers guys.
I have inlined my expressions in the past. The problem is, of course, that when they get large it can gets very difficult to read/maintain.
August 8, 2008 at 6:30 am
Please give this page a look:
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=273443
If this is something that you like please comment on it and I will also do the same.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy