2011年10月31日 星期一

星期 排序

在寫 access 的星期排序,竟發現無法排序..Orz
查了一下,果然無結果;倒是ms-sql 的解法,順便記錄下來了!
---
MS-SQL 星期排序方法:

1:
select * from tb
order by case 星期 when '星期一' then 1
when '星期二' then 2
when '星期三' then 3
when '星期四' then 4
when '星期五' then 5
when '星期六' then 6
when '星期日' then 7
end

2:
select   *   from   表  
order   by   charindex(字段, '星期一,星期二,星期三,星期四,星期五')

沒有留言:

張貼留言