Obsidian/Recognition/Work Related/1.업무메모/2022.04/2022-04-26.md

2.9 KiB

-- 제외대상


1.
.+[Send Packet].+null\$.+

2.
^((?!(?=.*[Send Packet])(?=.*null\$)).)*$

3.
\n\n -> \n

4.
 [0-9]+: 

5.
 : -> \t

6.
null\$925->null\t\$925


UPDATE tmp_gmtstd_log_ex
SET log_gbn = trim(LOG_GBN)

ALTER TABLE tmp_gmtstd_log ADD PRIMARY KEY (packet);


-- 각 컬럼 공백 제거
UPDATE TMP_GMTSTD_LOG_EX
SET LOG_DATE = trim(LOG_DATE)
, LOG_GBN = trim(LOG_GBN)
, LOG_DESC  = trim(LOG_DESC)
, PACKET  = trim(PACKET)


-- 제외할 패킷 이동
INSERT INTO TMP_GMTSTD_LOG_ex_ETC
SELECT *
FROM tmp_gmtstd_log_etc
WHERE LOG_DESC <> '[Send Packet (D-MFHF -> FSO)]'


-- 제외할 패킷 삭제
delete
FROM tmp_gmtstd_log_etc
WHERE LOG_DESC <> '[Send Packet (D-MFHF -> FSO)]'


-- 제외대상 패킷 확인
SELECT *
	FROM TMP_GMTSTD_LOG_ex tgl 
	WHERE NOT EXISTS (
	SELECT 'o' FROM TMP_GMTSTD_LOG tgle WHERE PACKET  = tgl.PACKET )
ORDER BY 1 DESC


-- 제외대상 패킷 제거
delete
	FROM TMP_GMTSTD_LOG tgl 
	WHERE EXISTS (
	SELECT 'o' FROM TMP_GMTSTD_LOG_EX tgle WHERE PACKET  = tgl.PACKET )

-- 중복 패킷 확인 6813 + 150 + 62
SELECT PACKET
FROM tmp_gmtstd_log
GROUP BY PACKET 
HAVING count(PACKET) > 1


-- 중복패킷 제거 작업용 임시테이블
CREATE TABLE tmp_maxpacket AS 
SELECT max(rowid) AS p_id, PACKET
	FROM tmp_gmtstd_log
	GROUP BY PACKET 
	HAVING count(PACKET) > 1

or

TRUNCATE TABLE  tmp_maxpacket

-- 임시테이블에 중복 패킷 저장
INSERT INTO tmp_maxpacket
SELECT max(rowid) AS p_id, PACKET
FROM tmp_gmtstd_log_etc
GROUP BY PACKET 
HAVING count(PACKET) > 1

-- 중복패킷 제거
DELETE
FROM TMP_GMTSTD_LOG tgl 
WHERE PACKET IN (
 SELECT PACKET  FROM tmp_maxpacket)
AND rowid NOT in(
 SELECT p_id FROM tmp_maxpacket )



-- 적용대상 패킷 건수 확인
-- 1195034 ($924 27건 제외)
SELECT count(*)
FROM tmp_gmtstd_log

-- 139527
SELECT count(*)
FROM tmp_gmtstd_log_etc


SELECT PAcket
FROM tmp_gmtstd_log
ORDER BY 1

SELECT PAcket
FROM tmp_gmtstd_log_etc
ORDER BY 1

최종 : 1334318
업데이트 : 1334318
  • log패킷 : 일자,시간 현재시간으로 바꿔버림
  • 밀어넣는데 시간이 오래걸림

SELECT max(RGSDE) FROM TB_FBB_LC tfl WHERE to_char(RGSDE, 'yyyymmdd') >= '20211201' --ORDER BY RGSDE DESC;

SELECT * FROM TB_FBB_LC tfl WHERE to_char(RGSDE, 'yyyymmdd') >= '20220118'

SELECT count(*) FROM TB_FILTERING tf WHERE to_char(RGSDE, 'yyyymmdd') >= '20211201'

SELECT count(*) FROM TB_LAST_LC_202203 WHERE out_dt IS NOT null

-- 선박별 최종 위치수신 시각

SELECT ts.SLOT_NO , ts.mmsi, ts.FSHRBT_NO , nvl((to_char(b.REPORT_DT + (9/24), 'yyyy-mm-dd hh24:mi:ss')), '-') AS last_day
, to_char(b.REPORT_DT + (9/24), 'yyyy-mm-dd hh24:mi:ss') AS auto_last_day
, c.last_day AS man_last_day
FROM TB_SHIP ts , TB_LAST_LC b, 
 (SELECT SLOT_NO , max(to_char(REPORT_DT + (9/24), 'yyyy-mm-dd hh24:mi:ss')) AS last_day
FROM TB_PASSIVLC_RSPNS
GROUP BY SLOT_NO 
 ) C
 WHERE ts.SLOT_NO = b.SLOT_NO (+)
 AND ts.SLOT_NO = c.slot_no(+)
 ORDER BY SLOT_NO