Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SELECT WITH 886 COLUNS IN WHERE - Base in AVERAGE AND STDEV by column

$
0
0

  • I have a tablewith 886 columns being allFLOATtypeand 700000 row,
  • would need to do a selectas below, butforall 886 columns.

DECLARE @Min float, @Max float;

set @Min = 0.9

set @Max = 1.1

SELECT [A], [B], [C],... [AHB]

   FROM [names] where

  [A]>(SELECTround(avg([A]), 2)* @min FROM [Names])and [A] )* @Max FROM [names])and

 [B]>(SELECTround(avg([B]), 2)* @min FROM [Names])and [B] )* @Max FROM [names])and

 [C]>(SELECTround(avg([C]), 2)* @min FROM [Names])and [C] )* @Max FROM [names])and 

 [A]>(SELECTround(avg([AHB]), 2)* @min FROM [Names])and [AHB])* @Max FROM [names]) 

  • VERY SLOW, SLOW

  • and also
  • make the clause where based on the column meanand 3 times the standard deviation of the column.

select [A], [B], [C],... [AHB]

from  [nomes] where

[A] >((SELECT round(avg([A]),2)FROM [nomes]) -(2 *((SELECT round(stdev([A]),2)  FROM [nomes]))))and 

[A] <((SELECT round(avg([A]),2)  FROM [nomes]) +(1 *((SELECT  round(stdev([A]),2) FROM [nomes]))))       AND

[B] >((SELECT round(avg([B]),2)FROM [nomes]) -(2 *((SELECT round(stdev([B]),2)  FROM [nomes]))))and 

[B] <((SELECT round(avg([B]),2)  FROM [nomes]) +(1 *((SELECT  round(stdev([B]),2) FROM [nomes]))))       AND

[C] >((SELECT round(avg([C]),2)FROM [nomes]) -(2 *((SELECT round(stdev([C]),2)  FROM [nomes]))))and 

[C] <((SELECT round(avg([C]),2)  FROM [nomes]) +(1 *((SELECT  round(stdev([C]),2) FROM [nomes]))))       AND

[AHB] >((SELECT round(avg([AHB]),2)FROM [nomes]) -(2 *((SELECT round(stdev([AHB]),2)  FROM [nomes]))))and 

[AHB] <((SELECT round(avg([AHB]),2)  FROM [nomes]) +(1 *((SELECT  round(stdev([AHB]),2) FROM [nomes]))))     





Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>