这两天在做一个star schema的东东, 被几个地方卡住, 想请教这里的大虾:
question 1
如何根据生日, 把1000个数据分成10年一组的group. 譬如说, 55岁的数据前insert进去属于50-60岁, 42数据属于40-50年龄组. 我现在做到
create table ageDim as
select to_char(sysdate, 'yyyy')-to_char(birthdate, 'yyyy') as age, decade(这里就不会做了)
from patient;question 2:
关于week的分组
数据仓库里约有2年多的数据, 需要按week分类, 是不是要用procedure做呢? 我又被卡住了叩请大虾指教.
question 1
如何根据生日, 把1000个数据分成10年一组的group. 譬如说, 55岁的数据前insert进去属于50-60岁, 42数据属于40-50年龄组. 我现在做到
create table ageDim as
select to_char(sysdate, 'yyyy')-to_char(birthdate, 'yyyy') as age, decade(这里就不会做了)
from patient;question 2:
关于week的分组
数据仓库里约有2年多的数据, 需要按week分类, 是不是要用procedure做呢? 我又被卡住了叩请大虾指教.
(2)周可以用trunc(op_date,'iw')分组
select to_char(sysdate, 'yyyy')-to_char(birthdate, 'yyyy') as age, trunc((to_char(sysdate, 'yyyy')-to_char(birthdate, 'yyyy'))/10) as decade
from patient;create table weekTable as
select to_char(ur_date, 'yyww') as weekId
from <tableName>;