게시일: Dec 25, 2011 11:29:0 PM
- PRESENTV(cell_reference, expr1, expr2)
: PRESENTNNV와 거의 유사
: PRESENTNNV 함수가 cell_reference로 명시된 값이 존재하거나 NULL이 아닐 경우에 expr1을 반환하는 반면,
PRESENTV 함수는 NULL이더라도 값이 존재하기만 하면 expr1을, 그렇지 않을 경우에는 expr2를 반환한다.
select col_years
, sex
, col_presentnnv_amt
, col_presentv_amt
from (select substr(months,1,4) years
, sex
, sum(amount) amount
from (select '201101' months, 'M' sex, 15000 amount from dual union all
select '201101' months, 'F' sex, null amount from dual ) -- 값이 null이지만 row는 존재함.
group by substr(months,1,4), sex
)
model return updated rows
partition by ( sex )
dimension by ( years col_years )
measures ( amount col_presentnnv_amt
, amount col_presentv_amt )
rules (
col_presentnnv_amt['2012'] = PRESENTNNV ( col_presentnnv_amt['2011'], 1, 0 )
, col_presentv_amt ['2012'] = PRESENTV ( col_presentv_amt ['2011'], 1, 0 )
)
order by 1, 2 desc;
------------------------------------------------------------
COL_YEARS SEX COL_PRESENTNNV_AMT COL_PRESENTV_AMT
------------------------------------------------------------
2012 M 1 1
2012 F 0 1
------------------------------------------------------------