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
Post a Comment