Subject | SQL - getting first and last row |
---|---|
Author | tickerboo2002 |
Post date | 2002-09-10T13:50:17Z |
Hello
I have a table with columns:
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.
....also, I assume I would need another query to get the row count
(Select count(*) from myTable) - is this the most efficient way of
getting the row count?
Thanks
David
I have a table with columns:
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.
....also, I assume I would need another query to get the row count
(Select count(*) from myTable) - is this the most efficient way of
getting the row count?
Thanks
David