-- [CQ-8-5-1]
SELECT /*+ NestLoop(t1 t2) */
t1.shop_id, MAX(t1.shop_nm) shop_nm ,COUNT(*) entry_cnt
FROM startdbpg.ms_shop_big t1
INNER JOIN startdbpg.tr_event_entry_big t2
ON (t2.shop_id = t1.shop_id)
WHERE t1.shop_oper_tp = 'DIST'
AND t1.shop_start_ymd LIKE '2018%'
AND t2.entry_dtm >= '2021-05-01'::date
AND t2.entry_dtm < '2021-06-01'::date
GROUP BY t1.shop_id
ORDER BY t1.shop_id;
SQL
복사
-- [CQ-8-5-2]
-- [1번 SQL]
SELECT t1.* ,t2.*
FROM startdbpg.ms_mbr_big t1
INNER JOIN startdbpg.tr_event_entry_big t2
ON (t1.mbr_id = t2.mbr_id)
WHERE t1.join_tp = 'SNS'
AND t1.mbr_gd = 'GOLD'
AND t2.entry_dtm >= '2024-12-23'::date
AND t2.entry_dtm < '2024-12-26'::date
AND t2.shop_id = 'S010';
-- [2번 SQL]
SELECT COUNT(*) entry_cnt
FROM startdbpg.tr_event_entry_big t1
WHERE t1.entry_dtm >= '2023-01-01'::date
AND t1.entry_dtm < '2023-01-11'::date
AND t1.mbr_id = 'M00107';
SQL
복사
-- [CQ-8-5-3]
SELECT t1.* ,t2.*
FROM startdbpg.ms_shop_big t1
INNER JOIN startdbpg.tr_event_entry_big t2
ON (t1.shop_id = t2.shop_id)
WHERE t2.entry_dtm >= '2024-01-01'::date
AND t2.entry_dtm < '2024-02-01'::date;
SQL
복사
