diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2022-12-12 10:33:18 +0100 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2022-12-12 10:33:32 +0100 |
| commit | cecf189f37fcf86a24862bf40283975e73392ca9 (patch) | |
| tree | c8f4afe119c5c0ad9a7a9a23e6a56df839678111 | |
| parent | e14d4da9dddbf81d1e0cb9ba83a3b95c6584b6dc (diff) | |
| download | perlweeklychallenge-club-cecf189f37fcf86a24862bf40283975e73392ca9.tar.gz perlweeklychallenge-club-cecf189f37fcf86a24862bf40283975e73392ca9.tar.bz2 perlweeklychallenge-club-cecf189f37fcf86a24862bf40283975e73392ca9.zip | |
plpgsql fixes
| -rw-r--r-- | challenge-195/luca-ferrari/postgresql/ch-1.sql | 3 | ||||
| -rw-r--r-- | challenge-195/luca-ferrari/postgresql/ch-2.sql | 9 |
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 |
