sql server - SQL identifying the first occurance in a list -
using sql server i'm trying label first occurrence in query result, results this...
i can identify first of each this:
can done case statement or similar? appreciated!
thanks
use of row_number() should enable this
select breakfast , case when rn = 1 1 else 0 end first_occur ( select breakfast , row_number() on (partition breakfast order id desc) rn your_table ) x
but isn't known order (i've assumed id desc), there might datetime or else in table use that.
Comments
Post a Comment