Re: [GENERAL] find the greatest, pick it up and group by

2011-05-17 Thread Phil Couling
Hi The method you're using is functionally correct and quite efficient if a little on the verbose side. Other non-postgres variants of SQL have a "DECODE" function which comes in very handy. I dont believe postgres has any equivalent. (Postgres decode() does something entirely differnt). I often

Re: [GENERAL] find the greatest, pick it up and group by

2011-05-16 Thread Ivan Sergio Borgonovo
On Mon, 16 May 2011 20:05:45 -0400 "David Johnston" wrote: > When asking for help on non-trivial SELECT queries it really helps > to tell us the version of PG you are using so that responders know > what functionality you can and cannot use. In this case > specifically, whether WINDOW (and maybe

Re: [GENERAL] find the greatest, pick it up and group by

2011-05-16 Thread David Johnston
age- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Ivan Sergio Borgonovo > Sent: Monday, May 16, 2011 7:39 PM > To: pgsql-general@postgresql.org > Subject: [GENERAL] find the greatest, pick it up and group by > > > I&

[GENERAL] find the greatest, pick it up and group by

2011-05-16 Thread Ivan Sergio Borgonovo
I've a table like: CREATE TABLE ordiniitem ( idordine numeric(18,0) NOT NULL, grupposped smallint, idart numeric(18,0) NOT NULL, qevasa integer, qfuoricat integer, qinris integer, qnonpub integer, qann integer, qord integer, qpren integer, qrichpag integer, qinriass integer