X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 74350DBF51 for ; Sun, 27 Nov 2005 07:43:00 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03828-04-3 for ; Sun, 27 Nov 2005 07:42:56 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id A88B2DBEC1 for ; Sun, 27 Nov 2005 07:42:47 -0400 (AST) Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by svr4.postgresql.org (Postfix) with ESMTP id BE51B5AF1DA for ; Sun, 27 Nov 2005 08:55:36 +0000 (GMT) Received: from a-kretschmer.de (p54B38885.dip0.t-ipconnect.de [84.179.136.133]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id jAR8jskV005859 for ; Sun, 27 Nov 2005 09:45:59 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 3.36 #1) id 1EgIF7-0000ei-00 for pgsql-sql@postgresql.org; Sun, 27 Nov 2005 09:50:41 +0100 Date: Sun, 27 Nov 2005 09:50:41 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: MAX, MIN and arrays Message-ID: <20051127085041.GA2081@kaufbach.delug.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/258 X-Sequence-Number: 23509 Colton A Smith schrieb: > Hi: > > Let's say I have a table with a column of one-dimensional arrays. What > exactly is returned when the database is queried for a maximum from that > particular column? The array was the greatest average value? Let's say What du you expect? test=# select * from foo; id | bar ----+--------- 1 | {1,2,3} 2 | {2,2,2} 3 | {3,2,1} (3 rows) Which row is the max()? test=# select max(bar) from foo; max --------- {3,2,1} (1 row) It compares the first value in every array. If you wish to compare the array depending on a other column, you can use somethink like test=# select id, bar from foo order by bar ; id | bar ----+--------- 1 | {1,2,3} 2 | {2,2,2} 3 | {3,2,1} (3 rows) test=# select id, bar from foo order by bar[3] ; id | bar ----+--------- 3 | {3,2,1} 2 | {2,2,2} 1 | {1,2,3} (3 rows) > I have a table with a column of two-dimensional arrays. What then? The same. HTH, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°