From f548780d9f6c71caa33950c52a2b5a3357824d10 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 2 Jun 2021 15:50:21 +0000 Subject: [PATCH] sort result sets by id --- route_sql/get_pool.sql | 4 +++- route_sql/list_changes.sql | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/route_sql/get_pool.sql b/route_sql/get_pool.sql index 2bc3c09..f083e39 100644 --- a/route_sql/get_pool.sql +++ b/route_sql/get_pool.sql @@ -82,8 +82,10 @@ GROUP BY ,tag ,comment ,substance +ORDER BY + logid ASC ) SELECT json_agg(row_to_json(rows)) x FROM - rows \ No newline at end of file + rows diff --git a/route_sql/list_changes.sql b/route_sql/list_changes.sql index 8bd09d4..9edd5d4 100644 --- a/route_sql/list_changes.sql +++ b/route_sql/list_changes.sql @@ -25,7 +25,7 @@ group BY ,jsonb_pretty(ol.doc) ,ol.id ORDER BY - (ol.doc->>'stamp')::timestamptz desc + ol.id desc ) SELECT - jsonb_agg(row_to_json(agg)::jsonb ORDER BY agg.stamp desc) x from agg + jsonb_agg(row_to_json(agg)::jsonb ORDER BY agg.id desc) x from agg