views:

47

answers:

1

Hi every body

I have an audit table that have data for insert, update and delete operations. I am writing a report that will display data in the order of Insert, Update and Delete. I don't think the order by clause will help. any help?

+4  A: 

You can use an ORDER BY combined with a CASE clause:

SELECT *
FROM auditlog
ORDER BY CASE operation_type
    WHEN 'Insert' THEN 1
    WHEN 'Update' THEN 2
    WHEN 'Delete' THEN 3
END
Mark Byers