Query 질문 드립니다.

슈토파이터 2014.09.05 10:32 Views : 2435

예전에 거래처 원장을 조회하는 폼을 질문 드려 도움을 받아 Query를 작성하였습니다..그러다 다른 방법이 생각나서 다시 질문 드립니다


select 0, '', '', '', '', 0, '' , '', '', '', sum(dr_amt)-sum(cr_amt) as dr_amt, 0
              from tbl_suntot as A3
                 where A3.com_id ='H'
                   and A3.comp_id ='H01'
                   and A3.acc_id ='108'
                   and A3.name_code = '0001'
                   and A3.inout_day >='20140000'
                   and A3.inout_day <'20140331'            전기이월 잔고
             
    
union all
   
select n_id, com_id, comp_id, sa_id, inout_day, slip_no, bill_id, n_remark, acc_id, name_code, dr_amt, cr_amt
from tbl_suninout as A3
                 where A3.com_id ='H'
                   and A3.comp_id ='H01'
                   and A3.acc_id ='108'
                   and A3.name_code = '0001'
                   and A3.inout_day >='20140101'
                   and A3.inout_day <='20140131'           1월 내역
union all


select 0, '', '', '', '', 0, '' , '', '', '', sum(dr_amt)as dr_amt,sum(cr_amt) as cr_amt
              from tbl_suntot as A3
                 where A3.com_id ='H'
                   and A3.comp_id ='H01'
                   and A3.acc_id ='108'
                   and A3.name_code = '0001'
                   and A3.inout_day >='20140101'
                   and A3.inout_day <='20140131'       1월 월계

union all


select n_id, com_id, comp_id, sa_id, inout_day, slip_no, bill_id, n_remark, acc_id, name_code, dr_amt, cr_amt
from tbl_suninout as A3
                 where A3.com_id ='H'
                   and A3.comp_id ='H01'
                   and A3.acc_id ='108'
                   and A3.name_code = '0001'
                   and A3.inout_day >='20140201'
                   and A3.inout_day <='20140231'     2월 내역

union all


select 0, '', '', '', '', 0, '' , '', '', '', sum(dr_amt)as dr_amt,sum(cr_amt) as cr_amt
              from tbl_suntot as A3
                 where A3.com_id ='H'
                   and A3.comp_id ='H01'
                   and A3.acc_id ='108'
                   and A3.name_code = '0001'
                   and A3.inout_day >='20140201'
                   and A3.inout_day <='20140231'   2월 월계


이렇게 12개월의 Query를 작성 했습니다  그런데 문제가 있어서 질문 드립니다.  조건을 2014/0101~2014/12/31 이 아닌

2014/02/01~2014/03/31 로 하면 해당 Query안되는 것 같습니다...이 일자 조회 처리를 어찌 해야 하는지요?

No. Subject Author Date Views
Notice SQL강좌: 챗GPT와 함께 배우는 SQL Server 무료 강좌 목차와 소개 (2023년 9월 업데이트) 코난(김대우) 2023.08.18 45335
Notice Python 무료 강좌 - 기초, 중급, 머신러닝(2023년 6월 업데이트) 코난(김대우) 2021.01.01 24224
8183 오라클 SP 문의입니다. [5] 착한이 2014.09.16 2688
8182 DB 복원중 도움 부탁 드립니다. [2] 에센이 2014.09.16 3618
8181 데이터 변경이력을 조회할 수 있나요? [3] 좋은친구 2014.09.15 3231
8180 Query 문 질문 드립니다. [2] 슈토파이터 2014.09.15 2411
8179 종속관계 삭제를 어떻게 해야하나요? 실실이 2014.09.12 2536
8178 top 관련 [5] 미라클 2014.09.12 2350
8177 2012 백업 방법 좀 알려주세요 [1] 전혜연 2014.09.12 1976
8176 수량 분할 조회 쿼리 질문있습니다. [2] 닝쿠 2014.09.11 3343
8175 Index 설정 전.. [3] SQL어렵.. 2014.09.11 2512
8174 스칼라반환함수관련 [2] HSQL 2014.09.11 2368
8173 두가지 상황에서 쿼리 속도 차이가 있을까요. [5] 애즈원 2014.09.11 2907
8172 두 서버간의 데이터 업데이트 [5] 파인드쿠폰 2014.09.11 3518
8171 LOG 파일 관리 [1] taz2315 2014.09.10 4376
8170 DB 서버명 변경 [1] taz2315 2014.09.10 3369
8169 log.ldf 파일 줄이기 [1] taz2315 2014.09.06 2649
8168 서버이전 후 IIS - MSSQL 간 연결 지연 문제 질문드립니다. [2] 야채호빵v 2014.09.05 3789
8167 두개의 쿼리문을 join 시켜 하나로 합치려 하는데 어렵네요.. [4] AutoCad 2014.09.05 3984
8166 dbnetlib connectionopen (connect()). sql server가 없거나 액세스할 수 없습니다 [1] 오락대장 2014.09.05 6829
» Query 질문 드립니다. [4] 슈토파이터 2014.09.05 2435
8164 테이블 두개의 차집합을 구하고 싶습니다. 도와주세요ㅠㅠ [3] 사이드사이드 2014.09.03 2954





XE Login