sql - derived columns in sybase -
i writing query define view on sybase database
. consider following example
select a, (b+c+d-e) derived_1, (b+c+d-e)+2 derived_2, (b+c+d-e)+4 derived_3 tablename
you can see calculate value using logic(b+c+d-e), apply more logic , return values different derived columns. there way can write (b+c+d-e) once ?
something
select a, (b+c+d-e) derived_1, derived_1+2 derived_2, derived_1+4 derived_3 tablename
wrap calculation in subquery,
select a, derived_1 + 2 derived_2, derived_1 + 4 derived_3 ( select a, (b+c+d-e) derived_1 tablename ) x
Comments
Post a Comment