쿼리 정리

This commit is contained in:
2026-06-24 20:25:30 +09:00
parent eca89b67d6
commit 8d6de2178a
2 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
-- ==========================================
-- 작업일자: 2026-06-22
-- 작 성 자: 류호성
-- 작업목적: [전자결재완료건을 결재상태를 접수상태로 수정하여 검토부서로 결재 상신 가능한 상태로 수정한다.]
-- 요청자/티켓번호: [전미현과장 / 요청번호 5953번]
-- 데이타베이스 : MY-SQL
-- ==========================================
-- [0] 결재정보에서 해당 전표번호로 조회하여 RT_Sanction(결재라인설정), RT_SanctionState(결재상태) 내용 확인하기
SELECT * FROM sanctiondoc_tbl WHERE detail2 LIKE '20260530-XE48-0002%'
-- [1] 결재진행상태 정보에서 해당 문서번호로 조회하여 결재상태 확인하기
SELECT * FROM sanctionstate_tbl WHERE docsn = '2026-11633-HF02560'
-- [2] 결재정보에서 RT_Sanction(결재라인설정), RT_SanctionState(결재상태)를 접수(RECEIVE) 가능한 상태로 수정하기
/*
START TRANSACTION;
UPDATE
sanctiondoc_tbl
SET
RT_Sanction = SUBSTRING(RT_Sanction, 1, INSTR(RT_Sanction,'RECEIVE')+6)
, RT_SanctionState = REPLACE(RT_SanctionState, '11:FINISH', '6:RECEIVE')
WHERE
docsn = '2026-11633-HF02560';
-- 결과가 올바르다면 반영, 잘못되었다면 되돌리기(ROLLBACK)
-- COMMIT;
-- ROLLBACK;
*/
-- [3] 결재상태정보에서 생성된 RECEIVE 행 삭제 - 참고)하위의 진행된 내역이 있으면 내용 검토 후 별도 조치해야 함.
-- SELECT * FROM sanctionstate_tbl WHERE docsn = '2026-11633-HF02560' AND SanctionState = 'RECEIVE'
/*
DELETE FROM
sanctionstate_tbl
WHERE
docsn = '2026-11633-HF02560' AND SanctionState = 'RECEIVE';
*/

View File

@@ -0,0 +1,41 @@
-- ==========================================
-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.]
-- 작 성 자: [실행자 이름을 기록합니다.]
-- 작업목적: [발주의뢰서 수량과 구매발주서 수량이 다른 것 조회하여 실무자에게 엑셀파일로 제공하여 수정하게 합니다.]
-- 요청자/티켓번호: [현업 혹은 매일 점검으로 자료 제공합니다.]
-- 데이타베이스 : MS-SQL
-- ==========================================
-- 발주의뢰서 수량과 구매발주서 수량이 다른 것 조회하기
select
'발주의뢰서 수량과 구매발주서 수량이 다른 것', a.por_no, a.por_seq, a.pjt_no, a.main, a.sub, a.bud_seq, a.item_name, a.qty, a.w_amt, b.qty, b.w_amt, (select emp from HPOIMS.dbo.gm_poim where poim = c.poim) emp_id
from
HPOIMS.dbo.gm_por_detail a
join
(
select
por_no, por_seq, sum(qty) qty, sum(w_amt) w_amt
from
HPOIMS.dbo.gm_po_detail
where
isnull(u_stat, '') <> 'D'
group by
por_no, por_seq
) b
on
a.por_no = b.por_no
and a.por_seq = b.por_seq
join
(
select distinct b.por_no, b.por_seq, a.poim from HPOIMS.dbo.gm_po a join HPOIMS.dbo.gm_po_detail b on a.po_no = b.po_no
) c
on
a.por_no = c.por_no
and a.por_seq = c.por_seq
where
a.pjt_no like 'V%'
and a.pjt_no in (select pjt_no from HPOIMS.dbo.ys_project where closing_yn = 'N' and pjt_no like 'V%')
and a.qty < b.qty
-- and a.qty <> b.qty
order by
a.por_no