本文介紹了Tsql 按特定字符串值對數(shù)據(jù)進行排序的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個審計表,其中包含用于插入、更新和刪除操作的數(shù)據(jù).我正在編寫一個報告,它將按插入、更新和刪除的順序顯示數(shù)據(jù).我認為 order by 條款不會有幫助.有什么幫助嗎?
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?
推薦答案
您可以將 ORDER BY 與 CASE 子句:
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
這篇關(guān)于Tsql 按特定字符串值對數(shù)據(jù)進行排序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!