X-Original-To: pgsql-php@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 153CB4758F1 for ; Sat, 22 Mar 2003 22:30:42 -0500 (EST) Received: from mail01.up.edu.ph (mail01.up.edu.ph [61.9.73.248]) by postgresql.org (Postfix) with SMTP id 374CC474E44 for ; Sat, 22 Mar 2003 22:30:35 -0500 (EST) Received: (qmail 5489 invoked by uid 504); 23 Mar 2003 03:50:14 -0000 Received: from ryanne.cruz@up.edu.ph by web1 with qmail-scanner-1.01 (update: v4253 19 Mar 2003. Clean. Processed in 3.548455 secs); 23 Mar 2003 03:50:14 -0000 Received: from unknown (HELO b01.mail.up.edu.ph) (10.16.3.1) by 10.16.3.142 with SMTP; 23 Mar 2003 03:50:10 -0000 Received: (qmail 16231 invoked by uid 504); 23 Mar 2003 03:37:06 -0000 Received: from ryanne.cruz@up.edu.ph by b01 with qmail-scanner-1.01 (update: v4253 19 Mar 2003. Clean. Processed in 0.456826 secs); 23 Mar 2003 03:37:06 -0000 Received: from unknown (HELO localhost) ([10.16.3.5]) (envelope-sender ) by 10.16.3.1 (qmail-ldap-1.03) with SMTP for ; 23 Mar 2003 03:37:06 -0000 Received: from 10.33.187.86 ( [10.33.187.86]) as user rocruz1@b04.mail.up.edu.ph by mail.up.edu.ph with HTTP; Sun, 23 Mar 2003 11:47:36 +0800 Message-ID: <1048391256.3e7d2e58a80b9@mail.up.edu.ph> Date: Sun, 23 Mar 2003 11:47:36 +0800 From: ryanne cruz To: "pgsql-php@postgresql.org" Subject: Re: max and sum function MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 User-Agent: Internet Messaging Program (IMP) 3.1 X-Originating-IP: 10.33.187.86 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=0.4 required=5.0 tests=FORGED_RCVD_TRAIL,USER_AGENT_IMP version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/34 X-Sequence-Number: 1946 hi list.=20 =20 does anyone here knows of a function that is similar to the sum function bu= t=20 involves more than one column? for example, i have a table with columns id,= =20 col1, col2 and col3. i want to get the max value from the three columns gru= ped=20 by an id.=20 =20 what i came up with is something like this:=20 =20 max1=3Dselect max(one) from (select sum(col1) as one from table group by id= );=20 max2=3Dselect max(two) from (select sum(col2) as two from table group by id= );=20 max3=3Dselect max(three) from (select sum(col3) as three from table group b= y=20 id);=20 =20 then i compare the 3 max values and get the maximum of the 3.=20=20 =20 is there an easier way to do this?=20 =20 thanks.=20 =20 ryanne=20=20 =20