Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A4793AF1395 for ; Sun, 22 Jan 2012 09:10:11 -0400 (AST) Received: from nm28-vm0.bullet.mail.ne1.yahoo.com ([98.138.91.22]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RoxBQ-0000U1-ST for pgsql-sql@postgresql.org; Sun, 22 Jan 2012 13:10:10 +0000 Received: from [98.138.90.55] by nm28.bullet.mail.ne1.yahoo.com with NNFMP; 22 Jan 2012 13:09:55 -0000 Received: from [98.138.87.6] by tm8.bullet.mail.ne1.yahoo.com with NNFMP; 22 Jan 2012 13:09:55 -0000 Received: from [127.0.0.1] by omp1006.mail.ne1.yahoo.com with NNFMP; 22 Jan 2012 13:09:55 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 545597.72089.bm@omp1006.mail.ne1.yahoo.com Received: (qmail 23601 invoked by uid 60001); 22 Jan 2012 13:09:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1327237795; bh=6/n86zfmxyQyaru9XdkcAGbiJt6hpRiP3mBXTSazYKk=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=kyE+zvCjvykpsnDIQ5+FF+2ZRxEtEQKXFFWKQSX4PyZqXyTRxJzqY/Yhw00Fh9Z3DubpkPeYhfGuOayaRc29Ze5P8FfLBgI5VhSOaXHL1c4nJ8RZaOpJzxDVSxgQcCtuZOOc69/FZRB7lQgu7LqJZ86yyncMbLoQ6t421bzElz0= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=gw0f/n2LN5OOoJlaVORpsw58ddr02RbhPdEoOyKguZqXlv8RcoDb7U9U+twCvE2bYolYJhaxh7ga4zUv3tbEACcB0mVuOvlrTY2mug5EVbLCJIA9k9QgoDGpZcPq93g5FyPijZpC7CKrp8k97ccxc6fxhykM6GfB5eij74YeNiw=; X-YMail-OSG: YroIFK0VM1n8VVcQ7Jg8teOQcGmX_wuqTsJFyMI3xbA61Y2 Wv8oKIu6YGmEaHEJd._5mPqTjJbWKX_Zt40f6RpdHKKi1Z7.YInN.YZcuVwU IANs5674pQvD46q0qP2.xiXKB34hqdrTIRECubbtcEGg9CDcylEGuMUWat8W iIJ.D61QFYlfWKSm5yCuM1cLCp8HcUjReJNfpKBAi1Y8Bz1BU861qsI_9yMv 7wgPjekIsHuQFgTWyDZfYMGVXm3kQWEc0xApzS14clJ1MgStz.K7Jt_Iy3Si HPU5RZjFOhR0QjnquLtL1QrAcJyKKp6fbSJdAKOtMEVy.evLlDtpHlrt.ekm 2l4yDgK8U1VM_UlDjTFmBA.fJnLxeoI6GDMkpJxZiuQHfg3m8AfP_pj.bRpP ilEYe.tdenlDFlSzd2GlleCrllSsyoLrPLyuY4BtmeWd9eGw6h2djT7rpiVI - Received: from [119.152.104.10] by web121606.mail.ne1.yahoo.com via HTTP; Sun, 22 Jan 2012 05:09:55 PST X-Mailer: YahooMailWebService/0.8.116.331537 Message-ID: <1327237795.19340.YahooMailNeo@web121606.mail.ne1.yahoo.com> Date: Sun, 22 Jan 2012 05:09:55 -0800 (PST) From: Rehan Saleem Reply-To: Rehan Saleem Subject: How to Return Table From Function To: "pgsql-sql@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="1458340343-1199520699-1327237795=:19340" X-Pg-Spam-Score: -0.6 (/) X-Archive-Number: 201201/98 X-Sequence-Number: 36269 --1458340343-1199520699-1327237795=:19340 Content-Type: text/plain; charset=us-ascii hi , i have created this function CREATE OR REPLACE FUNCTION totaloverlapcount(user_id integer , bg integer ,center_distance integer) RETURNS varchar AS $$ DECLARE percentage record; BEGIN select fname, lname, count(userid) totalcount ,100.00*count(useriddetails)/totaluser into percentage from users where userid= user_id and bloodgroup>=bg and (centredistance<=center_distance or center_distance=1) group by fname, lname, user_id; return percentage; its just a dummy function , but all i want to know that how can i return fname , lname totalcount and percentage from this function in the form of table , not the return type varchar. thanks --1458340343-1199520699-1327237795=:19340 Content-Type: text/html; charset=us-ascii
hi , i have created this function

CREATE OR REPLACE FUNCTION totaloverlapcount(user_id integer , bg integer ,center_distance integer)
RETURNS varchar AS $$

DECLARE percentage record;
BEGIN



select fname, lname, count(userid) totalcount ,100.00*count(useriddetails)/totaluser into percentage
from users
where userid= user_id and bloodgroup>=bg and
(centredistance<=center_distance or center_distance=1)
group by fname, lname, user_id;
return percentage;


its just a dummy function , but all i want to know that how can i return fname , lname totalcount and percentage from this function in the form of table , not the return type varchar.
thanks
--1458340343-1199520699-1327237795=:19340--