how can i get the last record

  • Hi!
    I am wondering how can i get the last record of a table .can u suggest me some scripts to do this.Say I have a table of subscriptions where we have the date and time of registration/and subsewuent membership renewel.I need to pull up the record for the first time he has subscribe..How can I do that..pls help
  • There is no such thing as a last record. You might want to consider this:

    USE NORTHWIND

    GO

    SELECT

     (SELECT

       OrderDate

     FROM

      Orders

     WHERE

      OrderID =

       (SELECT MIN(OrderID)

        FROM Orders)) AS First_Order

     ,

     (SELECT

       OrderDate

      FROM

       Orders

      WHERE

       OrderID =

        (SELECT MAX(OrderID)

        FROM Orders)) AS Last_Order

    First_Order                                            Last_Order                                            

    ------------------------------------------------------ ------------------------------------------------------

    1996-07-04 00:00:00.000                                1998-05-06 00:00:00.000

    (1 row(s) affected)

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply