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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -