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
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; min-height: 11.0px} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; color: #0433ff} span.s1 {color: #0433ff} span.s2 {color: #00f900} span.s3 {color: #929292} span.s4 {color: #000000} span.s5 {color: #ff40ff} </style> <style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; min-height: 11.0px} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; color: #0433ff} span.s1 {color: #0433ff} span.s2 {color: #00f900} span.s3 {color: #929292} span.s4 {color: #000000} span.s5 {color: #ff40ff} </style>

  • 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]))))     


<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica} span.s1 {color: #929292} </style>


Viewing all articles
Browse latest Browse all 24688

Trending Articles



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