how to Display records excluding the first one

  • Hi..

    I have a select statement like this:

    Select distinct(convert(varchar(6), date, 112)) as month from empskill order by month desc

    and the results are like this:

    201104

    201103

    201012

    201010

    I want to display the results excluding the 1st value (i.e) 201104, like this:

    201103

    201012

    201010

    How to write it in the query?

  • Try This and let me know if any issue

    SELECT MONTH

    FROM (SELECT DISTINCT( Convert(VARCHAR(6), DATE, 112) ) AS MONTH,

    Row_number() OVER(ORDER BY DATE DESC) row_id

    FROM empskill) t

    WHERE row_id > 1

    ORDER BY MONTH DESC

  • Hey, it returned duplicate values. distinct did not work. so I wrote like this :

    WITH mytable

    AS (SELECT DISTINCT CONVERT(VARCHAR(6), DATE, 112) AS MONTH

    FROM empskill)

    SELECT DISTINCT MONTH,

    Row_number () OVER (ORDER BY MONTH DESC) AS rownum

    FROM mytable

    and i removed the 1st record in SSRS dataset filters using rownum <> 1

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

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