1 of 1 people found this helpful
By sampled data I expect you mean archived data, which in PI terms is referred to as compressed data. For that you need to query the picomp/picomp2 "tables". The following example will return all the archived events between midnight and now:
SELECT tag, time, DIGSTRING(status) value FROM piarchive..picomp WHERE tag = 'cdm158' AND time >= 't'
If you mean sampled as in time-stepped data (every hour) you need to use the piinterp/piinterp2 "tables". This example will return values with 1 hour timestep, from yesterday (midnight) to today (midnight):
SELECT tag, time, DIGSTRING(status) FROM piarchive..piinterp WHERE tag = 'cdm158' AND time BETWEEN 'y' AND 't' AND timestep = '1h'
Use the picomp/piinterp-tables as shown if you want to output the actual digital states as text. For the picomp2/piinterp2-tables the status field will show the quality of data, and the actual value is found in the value field.
Thank you very much Asle
Digstring is the solution, the next query returns the correct data
SELECT time, DIGSTRING(status)
WHERE tag = 'FFH:B_002'
AND time BETWEEN 'y' AND 't'
AND timestep = '1h'
Regards, Emilio Sancha
PS: Add that by piinterp DIGSTRING (Status) returns digital status while using piinterp2 returns status value.