|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Thursday, March 04, 2010 12:19 AM
Points: 94,
Visits: 60
|
|
I want to Use expression value as column name in same query again
For eg:
select productname, (uprice+sprice) As pprice, CASE WHEN IsNull(pprice) Then '0' Else pprice End As pprice2 from products where active=1, productname is not null
Here pprice is the value I am calculating and want to be able to refer it in the same query without having to write the calculation again. This is just a simple example but the actual calculated column is complicated and very long and it makes it very difficult to debug if I have to use the same code again and again. Is there a cleaner way to do this in same query?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:57 PM
Points: 6,998,
Visits: 13,949
|
|
Please don't cross-post.
conversation is already ongoing over here:
http://www.sqlservercentral.com/Forums/FindPost821231.aspx
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|