Subject | Re: [ib-support] SQL - getting first and last row |
---|---|
Author | Martijn Tonies |
Post date | 2002-09-10T13:56:52Z |
Hi David,
ASC and UNION the result with only 1 row order it DESC.
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase
http://www.upscene.com
Firebird Workbench - the developer tool for Firebird
http://www.upscene.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."
> I have a table with columns:Have a look at the syntax for FIRST - take only 1 row, order it
>
> ID (PK - generator'ed), timestamp.
>
> Is it possible to get the first and last rows in one query? i.e. the
> highest and lowest ID, or the earliest and latest timestamp - either
> method should return the same rows.
ASC and UNION the result with only 1 row order it DESC.
> ....also, I assume I would need another query to get the row countYes - and it's slow :)
> (Select count(*) from myTable) - is this the most efficient way of
> getting the row count?
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase
http://www.upscene.com
Firebird Workbench - the developer tool for Firebird
http://www.upscene.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."