Is there a method to fetch the last value stored in a DB column with out having to read in the entir

  • Thread starter Thread starter DeWitt Phillips
  • Start date Start date
D

DeWitt Phillips

First let me say thank you. I am trying to extract the last value entered
into a database column without having to read through every value stored in
the column. Is that something that is easy to do?
 
It is easy if there's a column with a datetimestamp. You would just use the
datetimestamp in the WHERE clause, set the order to DESC and pick off the
very first record.
 
Providing you have a consectutive identity, then ordering by this in a
desending order - then selecting the first row (top 1)

e.g.
select top 1 yourField from yourTable order by id desc
 
Back
Top