diff --git a/pgsql/msgstore/select_projects_30_40.sql b/pgsql/msgstore/select_projects_30_40.sql index 1f71e5c..b876ddf 100644 --- a/pgsql/msgstore/select_projects_30_40.sql +++ b/pgsql/msgstore/select_projects_30_40.sql @@ -1,9 +1,14 @@ -select payload->>'community' Gemeinde, item Projekt, - payload->>'projectState' Status, payload->>'active' Aktiv, - to_char(tstamp, 'DD.MM.YYYY') Datum -from messages_current -where domain='kiss' and class='project' - and (payload->>'projectState')::integer <> 20 - --and payload->>'active' is not null - order by payload->>'community', item +select m2.id id1, m1.id idx, m1.payload->>'community' Gemeinde, m1.item Projekt, + m1.payload->>'projectState' Status, m1.payload->>'active' Aktiv, + to_char(m2.tstamp, 'DD.MM.YYYY') Datum1, + to_char(m1.tstamp, 'DD.MM.YYYY') Datumx +from messages_current m1, messages m2 +where m1.domain='kiss' and m1.class='project' + and (m1.payload->>'projectState')::integer <> 20 + --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 diff --git a/pgsql/msgstore/views.sql b/pgsql/msgstore/views.sql index b147f2b..0a42790 100644 --- a/pgsql/msgstore/views.sql +++ b/pgsql/msgstore/views.sql @@ -3,5 +3,5 @@ create or replace view messages_current as select id, domain, action, class, item, tstamp, payload from messages m1 where id = (select max(id) from messages m2 - where m2.domain = m1.domain and m2.action = m1.action - and m2.class = m1.class and m2.item = m1.item); + where m2.domain = m1.domain and m2.action = m1.action + and m2.class = m1.class and m2.item = m1.item);