sql server - Better use of redundant subquery in sql- case -


i have question sql- statements: possible "define sub query" multiple use in case. sounds bit confusing following example think clear have in mind:

select   column1,  column2,  case     when <bigsubquery> > 0 <bigsubquery>     else 0  end ... 

how can this, or can use. have such query works wonderful, huge code , not useable maintenance.

if using subquery, should put condition in subquery. instance, if have:

(select sum(x) . . . ) 

then do:

(select (case when sum(x) > 0 sum(x) else 0 end) . . . 

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 -