• I am not sure I follow your logic on the output and am concerned that you may you have oversimplified your problem in your post.

    based on what you have provided...here is one way to provide what you have requested

    SELECT

    minv_code

    , alert_msg

    , alert_time

    FROM @table

    ORDER BY minv_code,

    CASE WHEN alert_msg ='Meter' THEN 1

    WHEN alert_msg = 'Tamper' THEN 2

    WHEN alert_msg = 'Reverse' THEN 3

    ELSE 0

    END

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day