开发者

Tsql ordering data by specific string values

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?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜