From 006a1b010333355003f06f59bb6cdf40d6ba0703 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 18 Oct 2017 00:55:15 -0400 Subject: [PATCH] and query to show range of key values in transation table --- transaction_range.pgsql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 transaction_range.pgsql diff --git a/transaction_range.pgsql b/transaction_range.pgsql new file mode 100644 index 0000000..b4f469e --- /dev/null +++ b/transaction_range.pgsql @@ -0,0 +1,14 @@ +SELECT + t.srce + ,(ae.e::text[])[1] unq_constr + ,MIN(rec #>> ae.e::text[]) min_text + ,COUNT(*) cnt + ,MAX(rec #>> ae.e::text[]) max_text +FROM + tps.trans t + INNER JOIN tps.srce s ON + s.srce = t.srce + LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS_TEXT(defn->'unique_constraint'->'fields') WITH ORDINALITY ae(e, rn) ON TRUE +GROUP BY + t.srce + ,(ae.e::text[])[1] \ No newline at end of file