Create Discrete from 3 others Discretes

ORDER BY 1,2

So each one of these 3 queries is working just fine.  

Problem is:  i need another visualization combining these 3 queries but only datas where 


`state_motion value = 2`

 state_run  value = 1 

`state_mode value = 1`

How can I combine the 3 queries above with the conditions applied to state_motion, state_run and state_mode to generate a discrete plot?

I am really having a bad time trying to make this work.  IS there anyone available to help me?







Thanks

Hi “Stats”,

You have a really nice problem, what database do you have? version?

Hi @danielgonzalez
yes! i am having some troubles to get it done. I am using postgresql 13.
Thanks

Hi @statspy1977

It looks like you delete the queries, but as I remember it in that postgres version you could do something like:

SELECT  
	events.time,
	'Wear event' AS description,
		(LAG(tags.description) FILTER(WHERE tags.name = 'event_type_1') OVER (partition by name) = 'value1')
	AND (LAG(tags.description) FILTER(WHERE tags.name = 'event_type_2') OVER (partition by name) = 'value1')
	AND (LAG(tags.description) FILTER(WHERE tags.name = 'event_type_3') OVER (partition by name) = 'value1')
	AS value

FROM events
INNER JOIN tags
	ON tags.name = events.tag
WHERE 
		events.location = 6
	AND event.tag IN('event_type_1', 'event_type_2', 'event_type_3');

It’s just an idea since you delete your code xD