AnsweredAssumed Answered

Avoiding repeated values in SQL query of a digital point

Question asked by htrada on Mar 27, 2019
Latest reply on Mar 27, 2019 by rbiggins

Hi,

I´ve got to query a digital point with 2 states (AUTOMATICO/MANUAL) I'm interested in only getting rows when the value changes from one state to the other. In this case I get a lot of repeated values (see below) with the same state.

Is there any way to modify the query to achieve this?

Thanks in advance.

 

 

SELECT eh.Name Element, ea.Name Attribute, a.*

 

FROM [Logistica].Asset.ElementHierarchy eh

 

INNER JOIN [Logistica].Asset.ElementAttribute ea ON ea.ElementID = eh.ElementID

 

INNER JOIN [Logistica].Data.Archive a ON a.ElementAttributeID = ea.ID

 

WHERE eh.Path like N'\Ductos\Oleoductos\PRLP\Plantas\CA\DCI\%' and ea.name like N'Estado llave'

 

AND a.Time BETWEEN N'03/21/19 12:00:00' AND N'03/21/19 13:00:00' -- for details on supported timestamp literals, see PI SDK PITimeFormat.InputString property help

 

OPTION (FORCE ORDER)

 

 

Outcomes