aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-195/luca-ferrari/postgresql/ch-1.sql3
-rw-r--r--challenge-195/luca-ferrari/postgresql/ch-2.sql9
2 files changed, 11 insertions, 1 deletions
diff --git a/challenge-195/luca-ferrari/postgresql/ch-1.sql b/challenge-195/luca-ferrari/postgresql/ch-1.sql
index a736df90b1..c6cbc28437 100644
--- a/challenge-195/luca-ferrari/postgresql/ch-1.sql
+++ b/challenge-195/luca-ferrari/postgresql/ch-1.sql
@@ -16,7 +16,8 @@ BEGIN
SELECT count(*)
INTO freq
FROM regexp_split_to_table( i::text, '' ) as n(d)
- GROUP BY d;
+ GROUP BY d
+ ORDER BY 1 DESC;
IF freq = 1 THEN
counter := counter + 1;
diff --git a/challenge-195/luca-ferrari/postgresql/ch-2.sql b/challenge-195/luca-ferrari/postgresql/ch-2.sql
index c6b8cf318a..633ffc8c4f 100644
--- a/challenge-195/luca-ferrari/postgresql/ch-2.sql
+++ b/challenge-195/luca-ferrari/postgresql/ch-2.sql
@@ -3,6 +3,15 @@
CREATE SCHEMA IF NOT EXISTS pwc195;
+/*
+testdb=> select pwc195.task2_plpgsql( array[1,2,2,3,4,4,4,5,6,6,6,6]::int[] );
+NOTICE: relation "nums" already exists, skipping
+ task2_plpgsql
+---------------
+ 6
+
+*/
+
CREATE OR REPLACE FUNCTION
pwc195.task2_plpgsql( list int[] )
RETURNS int