Sunday, March 2, 2008

Custom ORDER BY in SQL

.NET provides very useful techniques for custom ordering, e.g. generic comparison delegate, lambda expressions, IComparable interface etc.

When the sort order is needed at database layer, you can use the following statement:

SELECT *

FROM ContestParticipants

ORDER BY

CASE result

  WHEN 'winner' THEN 1

  WHEN 'loser' THEN 2

  WHEN 'dnf' THEN 3

  ELSE 4

END



kick it on DotNetKicks.com

37 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
s45ad446512gd said...
This comment has been removed by a blog administrator.
Anonymous said...

美麗的事物是永恆的快樂,它的可愛日有增加,不會消逝而去..............................

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

人必須心懷希望,才會活的快樂,日子才過得充實,有意義,有朝氣,有信心。........................................

Anonymous said...

hello~welcome my world~<. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Anonymous said...

心中有愛,才會人見人愛。......................................................

Anonymous said...

以簡單的行為愉悅他人的心靈,勝過千人低頭禱告........................................

Anonymous said...

文章很棒~感謝!!..................................................

Anonymous said...

喜樂的心是健康良藥,憂傷的靈使骨枯乾。........................................

Anonymous said...

嘩做左推介BLOG 果然人氣勁旺 ........................................

雅婷 said...

成人貼站 中部視訊聊天 免費色情聊天室 av免費片 交友 最新女優排行 性感美女 777美女影片 學生妹偷拍 6k 聊天室 愛愛色情網 情趣影片 18禁免費看 台灣美少女自拍俱樂部 美腿影城 a片歐美 情色試看 色情榜 情色貼圖區 //bbs.x383.com/sexcity/ 完美女人影音聊天網 一夜情 情色美女圖 辣妹 人妻熟女系列 歐美超熟女 情人視訊 2009空姐招考 a片a圖分享區 美女自拍寫真 85cc免費影城85cc卡通 微風線上成人觀看 打嘟嘟成人網 777 貼圖貼片 援交桃園 嘟都情人色網 鋼管 無碼av貼圖 洪爺影視 大奶av女優免費看 sex520免費影片亞洲區 免費線上成人影片下載 巨乳 性愛持久 後宮網站 無碼 0204影城 免費線上性愛直播 走光秀

Anonymous said...

耐斯的部落格值得推蔫! ........................................

于呈均名 said...

Birth is much but breeding is more. 加油!..................................................

Anonymous said...

成熟,就是有能力適應生活中的模糊。..................................................

Anonymous said...

當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。 ..................................................

俊偉 said...

看看blog放鬆一下,工作累死了.................................................................

怡伶 said...

祝大家都平平安安健健康康!

Anonymous said...

成熟,就是有能力適應生活中的模糊。.................................................................

Anonymous said...

成熟,就是有能力適應生活中的模糊。....................................................................

Anonymous said...

It takes all kinds to make a world.............................................................

Anonymous said...

如果成為一支火柴,也要點亮一個短暫的宇宙;如果是一隻烏鴉,也要叫疼閉塞的耳膜。.................................................................

Anonymous said...

很喜歡你的blog哦...加油唷 ..................................................................

Anonymous said...

一時的錯誤不算什麼,錯而不改才是一生中永遠且最大的錯誤............................................................

Anonymous said...

不妄求,則心安;不妄作,則身安!......................................................

Anonymous said...

大家隨便說,說什麽都好,就是請不要惦惦............................................................

Anonymous said...

Pay somebody back in his own coin.............................................................

Anonymous said...

你好勁呀! 感謝!!!............................................................

Anonymous said...

耐心是一株很苦的植物,但果實卻很甜美。..................................................

Anonymous said...

Learn wisdom by the follies of others.............................................................

Anonymous said...

我對自己的信心已超越別人對我的評價................................................

文旺江汝 said...

A friend to everybody is a friend to nobody.............................................................

建邱勳 said...

百發百中不是一試就成的。..................................................

Anonymous said...

說「吃虧就是便宜的人」,多半不是吃虧的人。......................................................................

Anonymous said...

人生是故事的創造與遺忘。............................................................

Anonymous said...

cool blog,期待更新............................................................