Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



 



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux