PostgreSQL CREATE FUNCTION By Practical Examples

PHOTO EMBED

Fri Oct 15 2021 14:28:25 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

create function get_film_count(len_from int, len_to int)
returns int
language plpgsql
as
$$
declare
   film_count integer;
begin
   select count(*) 
   into film_count
   from film
   where length between len_from and len_to;
   
   return film_count;
end;
$$;
Code language: PostgreSQL SQL dialect and PL/pgSQL (pgsql)
content_copyCOPY

https://www.postgresqltutorial.com/postgresql-create-function/