From: | "Travis Hoyt" <thoyt(at)npc(dot)net> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Problems returning multiple columns |
Date: | 2002-05-01 16:51:29 |
Message-ID: | DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
CREATE FUNCTION wklyavg(numeric, timestamp, timestamp) RETURNS TEXT AS '
DECLARE
system ALIAS FOR $1;
startdate ALIAS FOR $2;
enddate ALIAS FOR $3;
result numeric;
BEGIN
result := (select (avg(usr) + avg(sys)) from sardata
where systemid = system and time between startdate
and enddate);
return enddate || result;
END;
' LANGUAGE 'plpgsql';
Above is the function I'm trying to run and I keep getting errors telling
me I need to cast my values. I've played with it a bit but not knowing
much about casting I was hoping for some help. I'm basically just summing
a couple of averages for values between two given dates. I wanted to
return the summed average and the "enddate" as one row. Any suggestions?
Thanks,
Travis
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-05-01 16:55:47 | Re: problem with update from subselect |
Previous Message | Nick Fankhauser | 2002-05-01 16:37:35 | Re: convert from sybase to postgresql |