Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id BEB0C2E33A0 for ; Mon, 7 Jan 2008 18:16:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 85137-07-3 for ; Mon, 7 Jan 2008 18:16:06 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.183]) by postgresql.org (Postfix) with ESMTP id 51C082E335C for ; Mon, 7 Jan 2008 18:16:06 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so13159811waf.5 for ; Mon, 07 Jan 2008 14:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=/LROhlmwHec67tc4P7VrPFhYjGid9fe76WmNoEUOjaU=; b=vS+StXLh0tA4E8SGZAtKVmOcIxyQYD4O0jVmCo/MgIwA+Vf+0H9JqRvmdD/ADm0xWmJ3ANifMgjT4jOxuSmcK7lFbQZ19bZDBE0GbKx1BVbSQNEa0DPUdHPm2tgzzzT/WzgkQAuG1wxHgRXjb9zlXnr0LmgMG6H3Kw4WkNXTkRY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FtF0KoIF7UTUWOyIfmdVG5NZcPnygi9FpNWa6wt9LM55sVYTHNVXin+Wa7eJ9liKpBe61A5JIzzmIqzhyv5hYkJLwGl1HbrM32eJigRPrPF+vfWieOdtKjo7kmyIcHpECvyOIEPFHkHalMu+RVBtsJlmvxOOg49FxTu3FlHLlfI= Received: by 10.114.195.19 with SMTP id s19mr22763261waf.57.1199744164944; Mon, 07 Jan 2008 14:16:04 -0800 (PST) Received: by 10.114.131.4 with HTTP; Mon, 7 Jan 2008 14:16:04 -0800 (PST) Message-ID: Date: Mon, 7 Jan 2008 16:16:04 -0600 From: "Scott Marlowe" To: emilu@encs.concordia.ca Subject: Re: Get the max(value1, value2, value3) from a table Cc: pgsql-sql@postgresql.org In-Reply-To: <4782A1B2.5050804@encs.concordia.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4782A1B2.5050804@encs.concordia.ca> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/34 X-Sequence-Number: 29887 On Jan 7, 2008 4:03 PM, Emi Lu wrote: > Greetings, > > Version: PostgreSQL 8.0.13 on i686-pc-linux-gnu > > I have a table test(col1, col2, col3) > > For each row, I'd like to get the "max"(col1, col2, col3). > > For example, test(1, 5, 2) > test(8, 1, 3) > test(12, 1, 1) > > > select ?max?(col1, col2, col3) as result; > will return > > result > ------- > 5 > 8 > 12 select max(col1) from table union all select max(col2) from table union all select max(col3) from table