Re: last row of table after csv import - Mailing list pgsql-novice

From Daniel Staal
Subject Re: last row of table after csv import
Date
Msg-id d09e52055ea3769ef21c26cf5006499f.squirrel@www.magehandbook.com
Whole thread Raw
In response to Re: last row of table after csv import  (Henry Drexler <alonup8tb@gmail.com>)
List pgsql-novice
On Tue, October 18, 2011 7:34 am, Henry Drexler wrote:

> perhaps first do a
> select
> count(*) from table
>
> then
>
> select
> *
> from
> table
> limit 1 offset (the result of your count(*) -1)

This would get you a random row of the table.  (Just a different random
row than without the offset.)

Easiest solution would be to add a new field to the table, that is an
increasing counter, and take the highest value of that counter.

But I have to ask: What is the actual problem you are trying to solve?
There's probably a better solution than getting the 'last row'.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------


pgsql-novice by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: last row of table after csv import
Next
From: "Dournaee, Blake"
Date:
Subject: enterprise support