Re: [SQL] Min and max element of an array column

2009-09-02 Thread A. Kretschmer
In response to Gianvito Pio : > Hello, > is it possible to obtain the minimum and the maximum single element of > an array column? > > Example: > [1, 2 ,5] > [3, -1, 6] > [9, 18,-4 ] > > I'd just like to make a query that gives me the min (-4) and the max(18) > of the column. Is that possible w

[SQL] Min and max element of an array column

2009-09-02 Thread Gianvito Pio
Hello, is it possible to obtain the minimum and the maximum single element of an array column? Example: [1, 2 ,5] [3, -1, 6] [9, 18,-4 ] I'd just like to make a query that gives me the min (-4) and the max(18) of the column. Is that possible without a function? Thanks -- Sent via pgsql-sql

Re: [SQL] Min and Max

2002-12-02 Thread Jean-Luc Lachance
If you do not mind non standard, how about: SELECT DISTINCT ON(id_father) * FROM children ORDER BY id_father, child_age; Dennis Björklund wrote: > > On 29 Nov 2002, Sergio Oshiro wrote: > > > How can I get the rows of the children name and its "father" such that > > they have the min child_age

Re: [SQL] Min and Max

2002-12-02 Thread Joel Burton
On Fri, Nov 29, 2002 at 10:55:54AM -0800, Sergio Oshiro wrote: > Hello, everybody! > > I've trouble to make a "simple"(?) query... > > The following table is an example: > > table: children > id_father | child_name | child_age > --++ > 1 | John | 2 >

Re: [SQL] Min and Max

2002-12-02 Thread Dennis Björklund
On 29 Nov 2002, Sergio Oshiro wrote: > How can I get the rows of the children name and its "father" such that > they have the min child_ages? > > -- the following does not return the child_name... > select id_father, min(child_age) from children group by id_father; > select id_father, max(child_a

[SQL] Min and Max

2002-12-02 Thread Sergio Oshiro
Hello, everybody! I've trouble to make a "simple"(?) query... The following table is an example: table: children id_father | child_name | child_age --++ 1 | John | 2 1 | Joe| 3 1 | Mary | 4 1 | Cristine | 4