create or replace function count_app_users()
returns table
(
total bigint
)
language plpgsql
as
$$
begin
return query (
select count(*) from app_user
);
end;
$$;
CREATE TABLE <table name> AS (
SELECT STATEMENT
)
SELECT count(*) FROM app_user;