From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: MAX, MIN and arrays
Date: Sun, 27 Nov 2005 09:50:41 +0100
Message-ID: <20051127085041.GA2081@kaufbach.delug.de> (raw)
In-Reply-To: <Pine.LNX.4.62.0511261208320.8351@cetus5.cs.utk.edu>
References: <Pine.LNX.4.62.0511261208320.8351@cetus5.cs.utk.edu>
Colton A Smith <smith@cs.utk.edu> 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°
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: akretschmer@spamfence.net
Subject: Re: MAX, MIN and arrays
In-Reply-To: <20051127085041.GA2081@kaufbach.delug.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox