Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Use results from one column for another column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

58 Posts

Posted - 01/04/2013 :  18:00:50  Show Profile  Reply with Quote
Doing this in SQL 2008.

Is it possible to use the results of one column to calculate another column? Example:

Select .. VERY LONG FORMULA as Results1

I need another column with a CASE so..

CASE Result1 < 100 Then something as Results2

Is it possible to do something like this or do I have to do the whole long formula again like...

CASE VERY LONG FORMULA < 100 Then something as Result2

I already have Results1 and it's silly to do it again just to calculate Results2.

God I hope this isn't too confusing.

Thanks in advance.

Using VS2010 / Learning in VB.Net / Win2008 R2 / SQL 2008 R2
Be kind to the newbies because you were once there.

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/04/2013 :  20:40:59  Show Profile  Reply with Quote
you can do in both ways


CASE VERY LONG FORMULA < 100 Then something as Result2

or make first result into derved table and then use it like

SELECT ....,
CASE Result1 < 100 Then something as Results2,

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000