First and Last in group function

  • I need to convert Access query to SQL store procedure.

    There are First and Last selection in Access Group function.

    How to code to replace First and Last in store procedure?

  • First = Top 1

    Last = Top 1 with inverted Order By

    For example:

    select

    (select top 1 MyColumn

    from MyTable

    Order By MyColumn) as First,

    (select top 1 MyColumn

    from MyTable

    Order By MyColumn desc) as Last;

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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