Re: get first and last row in one sql as two columns

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: get first and last row in one sql as two columns
Date: 2015-09-03 12:44:02
Message-ID: ms9fai$tpo$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Smith schrieb am 03.09.2015 um 14:11:
>>
>> SELECT first_value(col1) over (order by col1),
>> last_value(col1) over (order by col1)
>> FROM table;
>>

> The window function works for me (with adding limit 1 in the end to output only one row
> needed instead of many duplicate rows).

If that works for you with a LIMIT 1, then I don't understand why

select min(col1), max(col1)
from table

doesn't work for you

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ray Stell 2015-09-03 13:18:29 Installation of BDR from source
Previous Message Tom Smith 2015-09-03 12:11:13 Re: get first and last row in one sql as two columns