Last post Sep 18, 2019 05:23 AM by wmec
Aug 01, 2019 02:32 AM|InspiredJide|LINK
I was previously using Mysql now I ported to Postgres dbms. This means I have to port like 5 SP scripts to postgresql. I have been fighting with the first one for 48 hours. I am getting frustrated already. Please can some one help me here. Cos if I cant
resolve it. I would have to stay with Mysql.
CREATE OR REPLACE PROCEDURE Countit()
SELECT COUNT(*) FROM "Banks";
ERROR: syntax error at or near "SELECT"
LINE 5: SELECT COUNT(*) FROM "Banks";
SQL state: 42601
Please note that the table Banks already exits and I am running the script in the right database
Aug 02, 2019 10:08 AM|wmec|LINK
CREATE PROCEDURE Countit
SELECT COUNT(*) FROM Banks
Aug 02, 2019 02:40 PM|InspiredJide|LINK
did not work
Sep 18, 2019 05:23 AM|wmec|LINK
Re-try like the following example using a function
WITH a as (
SELECT DISTINCT adm0_a3, count(*) OVER (PARTITION BY adm0_a3) as freq,
count(*) OVER() as total_freq
SELECT a.adm0_a3, a.freq, a.total_freq,
) as relative_freq
OVER(ORDER BY b.relative_freq)::NUMERIC as suma_rel_freq
$$ LANGUAGE 'plpgsql'