Returning a unique set of values from a table

MrFlinstone 501 Reputation points

Hi All.

I have a table log as per below.


What I will like to do is return the last 3 release no's ordering by the release data.

In the case of the example below, that would be 77,66 and 55

The query below is not correct.

select releaseno  
(select distinct releaseno, releasedate  
from release_log  
order by releasedate desc) last_3_release_no_extract  
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,562 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Tom Cooper 8,466 Reputation points
    ;With cte As
    (Select releaseno, 
      Dense_Rank() Over(Order By releaseno Desc) As rk
    From release_log)
    Select releaseno
    From cte
    Where rk <= 3;


    0 comments No comments