정말모르겠네요 님이 쓰신 글 :
: MS-SQL만 만지다가 firebird를 사용하게 되었습니다.
:
: firebird는 from절에 서브쿼리가 안들어 가던데... 당췌 쿼리문을 못 만들겠네요.. ㅜ.ㅜ;
:
: table1
: --------------------------------
: a b c d
: --------------------------------
: 가 2 12 Y
: 나 3 0 N
: 다 6 2 N
: 가 90 87 Y
: 나 12 5 Y
:
: select a, sum(b), sum(c) from (
: select a, sum(b) as b, 0 as c from table1 where d='Y'
: group by a, d
: union all
: select a, 0 as b, sum(c) as c from table1 where d='N'
: group by a, d
: ) z
: group by a
:
: 이것좀 firebird 쿼리로 바꿔주세요... 부탁드립니다.
:
: 도와주세요~~~~
select a, sum( case d when 'Y' then b else 0 end) ,
sum( case d when 'N' then c else 0 end)
from table1 where d in ('Y','N')
group by a
|