SQL Server LIMIT top QUERY -
how can limit top query record.
example:
the result should until value of col2 b.
id col1 col2 7 1 6 2 5 1 4 3 b 3 1 2 4 1 1 b
you can use row_number() windowing function:
;with x ( select col1, col2, row_number() over(order id desc) rn table1 ) select col1, col2 x x1 not exists ( select 1 x x2 x2.rn <= x1.rn , x2.col2 = 'b' )
Comments
Post a Comment