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.
Author |
Topic |
pvong
Yak Posting Veteran
58 Posts |
Posted - 2013-01-04 : 18:00:50
|
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 Results1I need another column with a CASE so..CASE Result1 < 100 Then something as Results2Is 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 Result2I 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.Phil------------------------------Using VS2010 / Learning in VB.Net / Win2008 R2 / SQL 2008 R2Be kind to the newbies because you were once there. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-04 : 20:40:59
|
you can do in both wayseither CASE VERY LONG FORMULA < 100 Then something as Result2or make first result into derved table and then use it likeSELECT ....,CASE Result1 < 100 Then something as Results2,..FROM(SELECT ...,VERY LONG FORMULA as Results1FROM....)t ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|