FireBird Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
파이어버드 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
IBPhoenix
FireBird Main site
볼랜드포럼 광고 모집

FireBird Q&A
[1553] [질문]FireBird의 그룹별 합계내기..
아폴론 [] 1522 읽음    2005-09-14 17:37
1.select cast(gc_hmcd as varchar(4)) hmcd,cast(b.cd_des2 as varchar(22)) hmnm,
       cast(gc_desc as varchar(50)) neyg,cast(gc_srng as numeric) srng,
       cast(gc_dnka as numeric) dnka,cast(gc_amnt as numeric) amnt,
       cast(c.ad_clnm as varchar(50)) clnm
  from tr140t a
   left outer join tr010t  b on b.cd_iden = '3' and a.gc_hmcd = b.cd_code
   left outer join client  c on (a.gc_clcd = c.ad_clcd)
  where gc_krno = 'G200501050'
  union all
2.select cast(substring(gc_hmcd from 1 for 2)||'99' as varchar(4)) hmcd,
       cast(max(b.cd_des1||'소계') as varchar(22)) hmnm,
       cast('' as varchar(50)) neyg,cast(0 as numeric) srng,
       cast(0 as numeric) dnka,cast(sum(gc_amnt) as numeric) amnt,
       cast('' as varchar(50)) clnm
  from tr140t
   left outer join tr010t  b on b.cd_iden = '3' and gc_hmcd = b.cd_code
  where gc_krno = 'G200501050'
  group by substring(gc_hmcd from 1 for 2)
  union all
3.select cast('9999' as varchar(4)) hmcd,cast('전체계' as varchar(22)) hmnm,
       cast('' as varchar(50)) neyg,cast(0 as numeric) srng,
       cast(0 as numeric) dnka,cast(sum(gc_amnt) as numeric) amnt,
       cast('' as varchar(50)) clnm
  from tr140t
  where gc_krno = 'G200501050'

위 쿼리로
  1번의 실행으로 실제 데이터값 쫙~
  2번의 실행으로 그룹별 데이터 합이 쫙~
  3번의 실행으로 합계값이 나오긴 합니다.
인라인뷰가 되면 한번에 끝날 쿼리문인데요...

FireBird는 지원이 안되어서...

1.2.3번을 한데묵어 hmcd 값으로 소팅 할수 없을까요?
UDF로 하는 방법이라도 구체적으로 가르쳐 주실 수 없을까요?
감사합니다.

+ -

관련 글 리스트
1553 [질문]FireBird의 그룹별 합계내기.. 아폴론 1522 2005/09/14
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.