AnsweredAssumed Answered

I'm using following query to get hourly,monthly....tag averages. Can any one please let me know if this is the correct way of getting average tag values?

Question asked by Anithakash on Mar 26, 2016
Latest reply on Mar 30, 2016 by Anithakash

I'm using following query to get hourly,monthly....tag averages. Can any one please let me know if this is the correct way of getting average tag values?

 

SELECT * FROM OPENQUERY([OLEDB],'

Select

T5.td5 Descrpt,

T5.te5 Engunits,

T3.tv3 avg24hr,

T2.tv2 avg1hr,

T1.tv1 avg1mo

FROM

(SELECT tag tn1,value tv1,time tt1 FROM [piarchive]..[piavg] WHERE calcbasis = ''EventWeighted'') T1,

(SELECT tag tn2,value tv2,time tt2 FROM [piarchive]..[piavg] WHERE calcbasis = ''EventWeighted'') T2,

(SELECT tag tn3,value tv3,time tt3 FROM [piarchive]..[piavg] WHERE calcbasis = ''EventWeighted'') T3,

(SELECT tag tn5,descriptor td5,engunits te5 FROM [pipoint]..[pipoint]) T5

WHERE

T1.tn1=T2.tn2

AND T2.tn2 = T3.tn3

AND T3.tn3 = T5.Tn5

AND  T1.tn1 like ''WIN00*''

AND RIGHT(T1.tn1,5) in (''T0012'',

''T0013'',

''T0021'',

''T0054'',

''T0057'')

AND (T1.tt1 BETWEEN ''*-1mo'' AND ''*'')

AND (T2.tt2 BETWEEN ''*-1h'' AND ''*'')

AND (T3.tt3 BETWEEN ''*-24h'' AND ''*'')')......

Outcomes