AnsweredAssumed Answered

SQL query for Reletional Datasets

Question asked by igreguri Champion on Dec 21, 2016
Latest reply on Dec 23, 2016 by gregor

Hi,
I have problems with creating more complex query for Reletional Datasets.
I want to compare one set of PI points with other (density for storage tanks).

One set is naming like 'RT%D15.PV', and other 'RT%.D15.LA'
Values must be the same, but in some cases there is a difference.
I want to see on which pair of tags is difference in value or timestamp.


Here is my example, but I would different...

SELECT s.tag,d.descriptor, value, time, case when status = 0 THEN 'OK' ELSE 'BAD' END as status
FROM [piarchive].[pisnapshot] s
inner JOIN [pipoint].[classic] d ON s.tag = d.tag
WHERE s.tag LIKE 'RT%D15.PV' or s.tag LIKE 'RT%.D15.LA'

In this case, columns in table are:
tag
value
time
status

How to create query with this columns in table:
tag1 ('RT%D15.PV' )
value1
time1
tag2 ('RT%.D15.LA')
value2
time2
status (“BAD” if value1 <> value2 or “OK” if value1 = value2)

Regards,
Igor

Outcomes