Query using two different tags

#1

Hi everyone

I’m trying to get the first occurrence which attends both conditions. If I use “OR” it returns the data, but if I use “AND” I get nothing.

select first(value), tagCode from raw 
where (tagCode = 'TEMP_CAPTADOR_C3' and value > 70) 
or (tagCode = 'NIVEL_DONELLY' and value = 1) 

My sample data:

{"value": 78.4, "tagCode": "TEMP_CAPTADOR_C3", "time": "2017-06-07T08:35:19Z"},
{"value": 1, "tagCode": "NIVEL_DONELLY", "time": "2017-06-07T08:35:59Z"}

Thanks

#2

@rafaelncarvalho so you need it to return data with the AND condition and it is not?

#3

Correct. With “OR” it returns:

[{“tagCode”: “TEMP_CAPTADOR_C3”, “first”: 70.3, “time”: “2017-06-07T08:28:43Z”}]

With AND it should return at 08:33 but it returns an empty array

#4

So there is a way to do this?

#5

@rafaelncarvalho Currently you would need to do this with two queries or use Kapacitor to do this more advanced processing.