I'm learning how to create functions in Postgres. Below is a function I'm trying to get to return two numbers, but no matter what I try it always returns 0 rows.
Does anyone have any idea how I could get this function to work?
In the sections containing "blah blah blah" is my original query containing numerous tables that I'm joining together and some constraints I'm setting in the where section.
CREATE OR REPLACE FUNCTION "testFunction10"( integer)
RETURNS TABLE (
epc bigint,
stc bigint)
AS $$
BEGIN
RETURN QUERY select coutns.epc, coutns.stc
from
((select count(DISTINCT Association.rank) as epc, count(DISTINCT
oldest_pricing."startTime") as stc
from blah blah blah
left join balh blah blah and title_id = $1) -- input goes in here
left join blah blah blah
left join blah blah blah
where blah blah blah))coutns;
END;
$$ LANGUAGE plpgsql;
Example call:
select * from "testFunction10"(123);
Returns 0 rows.
((
and))
? – ypercubeᵀᴹ Nov 1 '16 at 0:55