with tbl as(
select '198845001' hk from dual union all
select '198845002' hk from dual union all
select '198845004' hk from dual union all
select '198945003' hk from dual union all
select '198945004' hk from dual union all
select '198945005' hk from dual union all
select '199045010' hk from dual union all
select '199045011' hk from dual union all
select '199045013' hk from dual union all
select '199145008' hk from dual union all
select '199145009' hk from dual union all
select '199145010' hk from dual union all
select '199245001' hk from dual union all
select '199245005' hk from dual union all
select '199345011' hk from dual union all
select '199345013' hk from dual union all
select '199345015' hk from dual
)
select (case when c.hk1 is null then '' else c.hk1 end) hk1
, (case when c.hk2 is null then '' else c.hk2 end) hk2
, (case when c.hk3 is null then '' else c.hk3 end) hk3
from
(
select (case when b.grp = '198' then yr end) hk1
, (case when b.grp = '199' then yr end) hk2
, (case when b.grp = '200' then yr end) hk3
, yr
from
(
select a.grp
, a.yr
from(
select distinct(substring(hakbun, 1, 3))grp
, substring(hakbun, 1, 4) yr
from alumni
)a
)b
)c;
제가 사용했던 쿼리는 이것인데 이걸로는 이런 데이터가 추출되지 않네요 ㅠ.ㅠ
쿼리로 방법이 있을까요?? (해당 쿼리는 mysql 짜여진 것입니다.)
hk 데이터는 2010년까지 들어있습니다. 2010년까지 다른 쿼리로 아래처럼 결과가 나오게 할 수 있나요??
hk1 hk2
---------------------
1988 1990
1989 1991
(null) 1992
(null) 1993
|