datetime functionality

  • I have a date field with couple of values. How to retreive the second highest date using a single SQL statement?

    Thanks & Regards.

  • Select max(CrDate) as SecondMax from dbo.SysObjects where CrDate not in (Select max(CrDate) from dbo.SysObjects)

  • It Works.Thanx Remi..

  • Top n from X rank (only one of so many ways)

    /*

    Ivica Masar

    pso@vip.hr

    */

    USE pubs

    DECLARE @var1 VARCHAR(12)

    DECLARE @var2 VARCHAR(30)

    SET ROWCOUNT 17

    SELECT @var1 = au_id, @var2 = au_lname FROM authors ORDER BY au_lname, au_id

    SET ROWCOUNT 0

    SELECT TOP 3 * FROM authors

    WHERE (au_id >= @var1 AND au_lname=@var2) OR ( au_lname>@var2)

    ORDER BY au_lname, au_id

  • or this....

    select top 1 Crdate from table

    where Crdate (select max(Crdate) from table)

    order by Crdate DESC







    **ASCII stupid question, get a stupid ANSI !!!**

  • AS I said, one of so many .

    How's that coin tossing coming Sushila??

  • Did you not get the video I sent you ?!?! It's been over 5 days since I mailed it!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Know the best part Remi - agrees with all laws of physics; no illegal moves and still makes me the winner! <;-)







    **ASCII stupid question, get a stupid ANSI !!!**

  • You don't even my adress... you could try to get your lies together before telling them .

  • I'll have to see that video to be sure of that.

  • Yes indeed - & just so I don't make your address public (I'm sure you don't want that) - let's just say that it went "across the border" to Canada to a certain house with a cat and a black belt!!!!!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Wrong house, got 2 cats and a dog.

  • Okay - just pick it up from the other place - will have them notify you!

    (Sorry!)







    **ASCII stupid question, get a stupid ANSI !!!**

  • Ya, I'll hold my breath... (30 M peeps in here).

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

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