必要な出力を取得する最良の方法は、次のことだと思います。
define startDate = to_date('2013-10-01', 'yyyy-mm-dd')
select type,
sum(case when MyDate = &&startDate then 1 else 0 end) as "1"
, sum(case when MyDate = &&startDate +1 then 1 else 0 end) as "2"
, sum(case when MyDate = &&startDate +2 then 1 else 0 end) as "3"
, sum(case when MyDate = &&startDate +3 then 1 else 0 end) as "4"
...etc for as many days of current month I am running
, sum(case when MyDate = &&startDate +29 then 1 else 0 end) as "30"
, sum(case when MyDate = &&startDate +30 then 1 else 0 end) as "31"--This would be commented out for Nov
from MyTabe
group by type
order by type
;
このようにして、11 月、12 月、1 月などにこれを実行したい場合は、上部の変数を変更してクエリを実行するだけです。これは私が探していたものです。ただし、列を動的に生成できるかどうかはまだ疑問ですが、見れば見るほどピボットテーブルが必要になると思います。