Question : USB ports problem

dear all
i have assembled PC in my office and it is working fine but when i plugged in my portable hard desk to it is USB ports the whole PC hanging and the temperature for hard desk increased
could you please advice
best regards

Answer : USB ports problem

Done correctly, it should not make any difference, the optimizer is smart enough to reuse expressions.
But your CTE will not work that way - it still needs the group by in the CTE itself, and you have not gained anything.

The ad-hoc view would look like this:

select sum(ColA), sum(ColB), MyVar from
(SELECT ColA, ColB,
 CASE @MyVar
     WHEN 1 THEN 'XXX'
     WHEN 2 THEN 'XXX'
     WHEN 3 THEN 'XXX'
     WHEN 4 THEN 'XXX'
 END MyVar
 FROM MyTable) v
group by MyVar

The CTE is the same.
Random Solutions  
 
programming4us programming4us