Re: [SQL ] PostgreSQL 欄位產生

看板Database作者 (○(* ̄中肯 ̄*)○)時間13年前 (2013/01/05 01:05), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
[恕刪] ※ 引述《Spake (史派克)》之銘言: : ◆ From: 24.103.231.10 : 推 mervynW:http://tinyurl.com/7vtfqk bank沒問題,但日期會很煩 01/04 12:39 : → Spake:看他的做法也是先把月份欄位寫進去,反而是下面的回應比較類 01/04 19:10 : → Spake:似我想要做的結果,畢竟我可以寫12個月份,但是天的話就... 01/04 19:12 就稍微加工唄: SELECT to_char(date '2007-01-01' + (n || ' month')::interval, 'mon') As short_mname FROM generate_series(0,11) n; 改成 select to_char ( (select min(date) from YourTable) + (n || ' day')::interval, 'yyyy-MM-dd' ) as short_mname from generate_series ( 0, (select DATE_PART('day', now() - (select min(date) from YourTable))::int) ) n; 簡單說就是把固定整數改掉。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.249.185.144
文章代碼(AID): #1GvmlSbq (Database)
文章代碼(AID): #1GvmlSbq (Database)