Re: query based on row number for psql8.3

Поиск
Список
Период
Сортировка
Искать
От
Stephen Tahmosh
Тема
Re: query based on row number for psql8.3
Дата
Msg-id
DM2PR0701MB1295F2FFD6EF372E3D89FE63C4810@DM2PR0701MB1295.namprd07.prod.outlook.com
Ответ на
Список
Дерево обсуждения
query based on row number for psql8.3 Emi <emilu@encs.concordia.ca>
Re: query based on row number for psql8.3 Adrian Klaver <adrian.klaver@aklaver.com>
Re: query based on row number for psql8.3 Rob Sargent <robjsargent@gmail.com>
Re: query based on row number for psql8.3 Stephen Tahmosh <stahmosh@shieldsrx.com>
Re: query based on row number for psql8.3 Michael Moore <michaeljmoore@gmail.com>
Re: query based on row number for psql8.3 Stephen Tahmosh <stahmosh@shieldsrx.com>
Re: query based on row number for psql8.3 "David G. Johnston" <david.g.johnston@gmail.com>
Re: query based on row number for psql8.3 Stephen Tahmosh <stahmosh@shieldsrx.com>
Re: query based on row number for psql8.3 Adrian Klaver <adrian.klaver@aklaver.com>
Re: query based on row number for psql8.3 Stephen Tahmosh <stahmosh@shieldsrx.com>
A "goggle" of row_number()  function for postgresql seems to indicate its only available in 8.4 and above :-(

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Stephen Tahmosh
Sent: Wednesday, March 23, 2016 2:10 PM
To: emilu@encs.concordia.ca; pgsql-sql@postgresql.org
Subject: Re: [SQL] query based on row number for psql8.3

Row_number is an "analytic" function, used in conjunction with the "partition by"
Ror_number is a logical concept so depends on the "order by" component of the "partition by" clause

You need to wrap your query with row_number in an outer query and apply thye case statement to the outer query.

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Emi
Sent: Wednesday, March 23, 2016 2:01 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] query based on row number for psql8.3

Hello,

For psql8.3, is there a simple way to query based on row number please?

For example,

select  case                    when row_num=1 THEN    t1.tot_hr                    ELSE                                  t1.tot_hr -
t1.pre_hr          END
FROM  t1 ;





--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
THIS MESSAGE (AND ALL ATTACHMENTS) IS INTENDED FOR THE USE OF THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient, your use of this message for any purpose is strictly prohibited. If you have received this communication in error, please delete the message without making any copies and notify the sender so that we may correct our records. Thank you.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
THIS MESSAGE (AND ALL ATTACHMENTS) IS INTENDED FOR THE USE OF THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient, your use of this message for any purpose is strictly prohibited. If you have received this communication in error, please delete the message without making any copies and notify the sender so that we may correct our records. Thank you.
В списке pgsql-sql по дате отправления
От: Stephen Tahmosh
Дата:
От: David G. Johnston
Дата:
FAQ