-- 목록
-- 30000 만포인트 지급 
 select ch.member_idx,mb.id,mb.level, mb.point, mb.money from member_money_charge_history as ch 
 left join member as mb 
 on ch.member_idx = mb.idx
 where ch.update_dt between '2022-08-10 00:00:00' and '2022-09-08 23:50:00' and ch.status = 3 and mb.level not in (4,5,9) and mb.u_business = 1 
 and mb.status = 1
 group by ch.member_idx having count(ch.member_idx) > 0;
 
 -- 50000 포인트 지급 
 select ch.member_idx,mb.id,mb.level, mb.point, mb.money from member_money_charge_history as ch 
 left join member as mb 
 on ch.member_idx = mb.idx
 where ch.update_dt between '2022-08-10 00:00:00' and '2022-09-08 23:50:00' and ch.status = 3 and mb.level in (4,5) and mb.u_business = 1
 and mb.status = 1
 group by ch.member_idx having count(ch.member_idx) > 0;
 
-- 지급
-- 30000 만포인트 지급 
update member set point = point + 30000 where idx in (
	select mb.idx from member_money_charge_history as ch 
	left join member as mb 
	on ch.member_idx = mb.idx
	where ch.update_dt between '2022-08-10 00:00:00' and '2022-09-08 23:50:00' and ch.status = 3 and mb.level not in (4,5,9) and mb.u_business = 1 
	and mb.status = 1
	group by ch.member_idx having count(ch.member_idx) > 0
);

-- 50000 만포인트 지급 
update member set point = point + 50000 where idx in (
	select ch.idx from member_money_charge_history as ch 
	left join member as mb 
	on ch.member_idx = mb.idx
	where ch.update_dt between '2022-08-10 00:00:00' and '2022-09-08 23:50:00' and ch.status = 3 and mb.level in (4,5) and mb.u_business = 1
	and mb.status = 1
	group by ch.member_idx having count(ch.member_idx) > 0
);

