Monday, July 7, 2014

Calling the case condition inside the partition using row_number

,ROW_NUMBER() OVER (PARTITION BY CustomerId ORDER BY CASE [status]
WHEN 'active' THEN 1
WHEN 'new' THEN 2
WHEN 'cancelled' THEN 3
ELSE 4
END) AS RN

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.