mysql - SQL Reference Large Equation in Select Statement -


i have large equation in select statement need reference in statement think eating efficiency, not want reference more need to.

select 'headerdetail' rowtype, ... , [large case/when statement] tracking ... not(@dnc in([large case/when statement])) , [large case/when statement] not null 

i feel each time call statement need recalculate values , query takes few seconds run. there way reference statement without having run sub query multiple times?

thanks in advance help!

what happens when filter rows in outer query or cte.

with cte  ( select 'headerdetail' rowtype, ... , [large case/when statement] tracking ... ) select * cte not(@dnc in(tracking)) , tracking not null 

or use sub-select

select *  ( select 'headerdetail' rowtype, ... , [large case/when statement] tracking ... ) not(@dnc in(tracking)) , tracking not null 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -