AnsweredAssumed Answered

previous event minus present event & previous value minus present value in PI SQL

Question asked by limesh on Feb 23, 2016
Latest reply on Feb 24, 2016 by gregor

Hi,

I am looking for a query in PI SQL commander for  previous event-present event and previous value - present value.

I have written a query for the same but i am facing some issue with syntax, Please can any one help me on this.

 

1)previous event minus present event

select a.value,a.time,a.Previous_event,DATEDIFF(second,a.time,a.Previous_event)   from (

select tag,time,value,Prevevent('sinusoid',time) as Previous_event

FROM piarchive.picomp2

   WHERE tag = 'sinusoid'  and time between '*-10m' and '*') as a

 

 

2)previous value minus present value

select a.tag,a.time,a.value-a.Previous as prev_val from (

select tag,time,value,PrevVal('sinusoid',time) as Previous

FROM piarchive.picomp2

   WHERE tag = 'sinusoid'  and time between '*-10m' and '*') as a

Error =[-] Overload resolution failed for (Variant, Variant) argument(s).

 

Can you please suggest with this query ... Thanks in advance !

 

Regards,

Prasad.N

Outcomes