Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 9A8B72E3461 for ; Mon, 7 Jan 2008 18:40:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 25433-02-2 for ; Mon, 7 Jan 2008 18:39:51 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.176]) by postgresql.org (Postfix) with ESMTP id 9487F2E4202 for ; Mon, 7 Jan 2008 18:40:05 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so13170838waf.5 for ; Mon, 07 Jan 2008 14:40:04 -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=iM7BcakMTM+gq/BKvk2nO1qccJt7kSBH7zlRD1Ss+Hc=; b=QUSH9iDUGg7BjMts1Tm4v+S1V+Et4wlFnmxLS/7/xuQoyvhiv2LqjMtq1RvZcWRD5hf8qT3C8QMX5prZ6qfWMuJgds5T5tJPiA5E4v6P271Z9yeFKqgQ1VR9U7v69Vck75C1aMJytisCqEC6hUTUIAiJ7Y6Mk5KJyyjgVqwxx0g= 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=G8yjWzUJwXSxFuPX8xR9P5jgZWtwm2TlirCO6BDSuvuTZifTwG/GyvajqG74A9dO+1rjLgY3akFfsmWqgW5np+ABkHmaaCS4aadouCLX2lu8ETSI9QJQslh3fcHokzdYD+oCTIiYSsXAX1MFYgM16rAtAUl/LgBiQOzD3z/Etsw= Received: by 10.114.171.1 with SMTP id t1mr6167911wae.83.1199745604344; Mon, 07 Jan 2008 14:40:04 -0800 (PST) Received: by 10.114.131.4 with HTTP; Mon, 7 Jan 2008 14:40:04 -0800 (PST) Message-ID: Date: Mon, 7 Jan 2008 16:40:04 -0600 From: "Scott Marlowe" To: emilu@encs.concordia.ca Subject: Re: Get the max(value1, value2, value3) from a table Cc: "Richard Broersma Jr" , pgsql-sql@postgresql.org In-Reply-To: <4782A9C4.1030104@encs.concordia.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <239138.99803.qm@web31804.mail.mud.yahoo.com> <4782A9C4.1030104@encs.concordia.ca> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/39 X-Sequence-Number: 29892 On Jan 7, 2008 4:37 PM, Emi Lu wrote: > > > > >> select max(col1) from table > >> union all > >> select max(col2) from table > >> union all > >> select max(col3) from table > No, this is not what I prefer; it makes complicate query. Generally speaking when you have to make complicated queries to get simple answers, then it's likely you have a normalization issue. IF col1, col2, col3 were all a single column in an external table the answer would likely fall out a little simpler. But honestly, that's not a real complex query. PostgreSQL handles far more complex queries for me everyday with hardly a murmer..