Skip to main content

Posts

Showing posts with the label SQL

ORACLE SQL自訂排序(order by decode)

SELECT ID,description FROM A ORDER BY ID 11     台中市 13     彰化縣 14     南投縣 21     台北市 22     新北市 23     基隆市 24     桃園縣 25     新竹縣 26     新竹市 27     苗栗縣 SELECT ID,description FROM A ORDER BY  decode (ID, '21',  1 , '22',  2 , '23',  3 , '24',  4 ), ID 21     台北市 22     新北市 23     基隆市 24     桃園縣 11     台中市 13     彰化縣 25     新竹縣 26     新竹市 27     苗栗縣 註解: T ranslate ID  '21' into the value 1, ID '22'  into the value 2