From: | Michael Moore <michaeljmoore(at)gmail(dot)com> |
---|---|
To: | Stephen Tahmosh <stahmosh(at)shieldsrx(dot)com> |
Cc: | Rob Sargent <robjsargent(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: query based on row number for psql8.3 |
Date: | 2016-03-23 20:34:48 |
Message-ID: | CACpWLjOH5EUdHXozQNop_nnNdQf1kx39kziz1is42mUVEQyuNA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
It was hinted at in previous responses, but if you do:
Select * from t1;
and then again
select * from t1;
You have no guarantee that the results will be in the same order. So, even
if your query DID work, it would be meaningless because you should*
consider* the records to come in a random order. Never assume the order,
always specify it if it is important.
Mike
On Wed, Mar 23, 2016 at 11:57 AM, Stephen Tahmosh <stahmosh(at)shieldsrx(dot)com>
wrote:
>
>
> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org [mailto:
> pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Rob Sargent
> Sent: Wednesday, March 23, 2016 2:27 PM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: Re: [SQL] query based on row number for psql8.3
>
>
>
> On 03/23/2016 12:00 PM, Emi wrote:
> > 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 ;
> >
> >
> >
> >
> >
> I seem to recall other posts from condordia: Someone needs to take of
> their skates and update postgres!
>
> [ST]
> I'm not sure if this link works, as I don't have access to 8.3
>
> http://postgresql.nabble.com/How-to-realize-ROW-NUMBER-in-8-3-td4328448.html
>
> If this works, then wrap the query with a main query that uses "rownum" in
> the case statement.
>
> STeve
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Moore | 2016-03-28 22:51:18 | need advice for simple web development tools |
Previous Message | Michael Moore | 2016-03-23 19:24:01 | Re: simple function index question |