46 lines
2.2 KiB
Transact-SQL
46 lines
2.2 KiB
Transact-SQL
-- ==========================================
|
|
-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.]
|
|
-- 작 성 자: [실행자 이름을 기록합니다.]
|
|
-- 작업목적: [기간에 대한 회계 장부 전체를 조회하여 다량의 자료를 엑셀파일로 제공합니다.]
|
|
-- 요청자/티켓번호: [회계부서의 요청에 따라 제공합니다.]
|
|
-- 데이타베이스 : MS-SQL
|
|
-- ==========================================
|
|
|
|
declare @fr_date char(8), @to_date char(8), @yy char(4)
|
|
|
|
-- [0] 변경할 데이터 설정
|
|
select @fr_date = '20240101', @to_date = '20241231', @yy = '2024'
|
|
|
|
-- [1] 해당 기간의 회계 장부 내역을 조회
|
|
select
|
|
a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode
|
|
, acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and substring(a.acntcode, 1, 5)+'00' = acntcode)
|
|
, acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and a.acntcode = acntcode)
|
|
, a.apvdramt, a.apvcramt
|
|
, replace(a. slpfree, '"',''), a.pjtno
|
|
, pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no)
|
|
, a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code), a.hyundae
|
|
from
|
|
ACC.dbo.t23a10 a
|
|
where
|
|
a.area = '9'
|
|
and a.apvdate between @fr_date and @to_date
|
|
and a.acntcode is not null
|
|
and a.hyundae = '2'
|
|
union all
|
|
select
|
|
a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode
|
|
, acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and substring(a.acntcode, 1, 5)+'00' = acntcode)
|
|
, acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and a.acntcode = acntcode)
|
|
, a.apvdramt, a.apvcramt
|
|
, replace(a. slpfree, '"',''), a.pjtno
|
|
, pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no)
|
|
, a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code), a.hyundae
|
|
from
|
|
ACC.dbo.t23a10 a
|
|
where
|
|
a.area = '9'
|
|
and a.apvdate between @fr_date and @to_date
|
|
and a.acntcode is not null
|
|
and a.hyundae = '1'
|