improve example select on messages_current view

This commit is contained in:
Helmut Merz 2025-09-10 08:46:31 +02:00
parent 588a556ede
commit df76b3771f
2 changed files with 15 additions and 10 deletions

View file

@ -1,9 +1,14 @@
select payload->>'community' Gemeinde, item Projekt, select m2.id id1, m1.id idx, m1.payload->>'community' Gemeinde, m1.item Projekt,
payload->>'projectState' Status, payload->>'active' Aktiv, m1.payload->>'projectState' Status, m1.payload->>'active' Aktiv,
to_char(tstamp, 'DD.MM.YYYY') Datum to_char(m2.tstamp, 'DD.MM.YYYY') Datum1,
from messages_current to_char(m1.tstamp, 'DD.MM.YYYY') Datumx
where domain='kiss' and class='project' from messages_current m1, messages m2
and (payload->>'projectState')::integer <> 20 where m1.domain='kiss' and m1.class='project'
--and payload->>'active' is not null and (m1.payload->>'projectState')::integer <> 20
order by payload->>'community', item --and m1.payload->>'active' is not null
and m2.id = (select min(id) from messages m3
where m3.domain = m1.domain and m3.action = m1.action
and m3.class = m1.class and m3.item = m1.item
and m3.payload->>'projectState' = m1.payload->>'projectState')
order by m1.payload->>'community', m1.item
-- \g projects_10_30_40.csv -- \g projects_10_30_40.csv

View file

@ -3,5 +3,5 @@ create or replace view messages_current as
select id, domain, action, class, item, tstamp, payload select id, domain, action, class, item, tstamp, payload
from messages m1 from messages m1
where id = (select max(id) from messages m2 where id = (select max(id) from messages m2
where m2.domain = m1.domain and m2.action = m1.action where m2.domain = m1.domain and m2.action = m1.action
and m2.class = m1.class and m2.item = m1.item); and m2.class = m1.class and m2.item = m1.item);