ピボットテーブルで連続した日付を作る

 

ピボットテーブルの作成

 #!/usr/bin/env perl
 print "create table pivot ( id int );\n";
 for (0 .. 99) {
    print "insert into pivot values ( $_ );\n";
 }
 ./pivot.pl > sql.txt
 psql my_db < sql.txt

連続した日付を作る

2010年1月1日以降の日付を作る。

 SELECT (date '2010-01-01' + id::integer) FROM pivot;

参考

http://www.postgresql.jp/document/pg833doc/html/functions-datetime.html


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2010-03-27 (土) 20:49:44