Jump to content

SQL HELP

- - - - -

  • Please log in to reply
1 reply to this topic

#1
stevie754

stevie754

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Hi all,
I'm a little stuck writing some SQL code to find the last value in a table and find the data stored between it and the previous value.
What I mean is every time a row is added into the table it is given a timestamp. I want to be able to find all data in the table between the latest timestamp and the previous. I have this so far but I'm useless at SQL any ideas would be really appreciated.

SELECT LAST(TIMEOCCURREDKEY) AS LASTTIMEOCCURREDKEY FROM PROCESSHISTORY

SELECT *
FROM PROCESSHISTORY
WHERE LASTTIMEOCCURREDKEY
SET TIMETEST = LASTTIMEOCCURREDKEY-1
BETWEEN TIMETEST and LASTTIMEOCCURREDKEY

This is what I have at the minute. I'm sorry if I didn't explain very well

Thanks

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What database platform is this?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users