Re: [SQL] obtaining difference between minimum value and next in size

2010-11-18 Thread Oliveiros d'Azevedo Cristina
John, Great to hear it helped you out Best, Oliver - Original Message - From: John Lister To: pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 10:46 PM Subject: Re: [SQL] obtaining difference between minimum value and next in size Cheers oliverios and tom for

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
groups. John - Original Message - From: Oliveiros d'Azevedo Cristina To: John Lister ; pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 4:09 PM Subject: Re: [SQL] obtaining difference between minimum value and next in size Hi, John. I am not familiar wit

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread Oliveiros d'Azevedo Cristina
ster To: pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 3:11 PM Subject: [SQL] obtaining difference between minimum value and next in size Hi, I was wondering if it is possible to do this with a single query rather than iterate over all of the rows in an application: I h

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread Andreas Kretschmer
John Lister wrote: > Hi, I was wondering if it is possible to do this with a single query rather > than iterate over all of the rows in an application: > > I have a table which for brevity looks like: > create table offers { > integer id; > integer product_id; > double price; > } > > wh

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread Tom Lane
"John Lister" writes: > Is it possible to obtain the difference between just the minimum price and > the next one up per product, If you're using >= 8.4, try a window function. LEAD or LAG ought to do it. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql

[SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
Hi, I was wondering if it is possible to do this with a single query rather than iterate over all of the rows in an application: I have a table which for brevity looks like: create table offers { integer id; integer product_id; double price; } where for each product there is a number of of