• Maybe this?

    WITH cte AS (

    SELECT *,

    ROW_NUMBER() OVER(PARTITION BY st_no ORDER BY year, month) AS seq

    FROM @t

    )

    SELECT a.st_no, a.year, a.month, a.sal

    FROM cte a

    WHERE NOT EXISTS(SELECT * FROM cte b

    WHERE a.st_no=b.st_no

    AND a.sal=b.sal

    AND a.seq=b.seq+1)

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537