#문제1
select count(1) from payment p
where pay_type like "%MONEY%" and p.pay_amount >= 500000;
#문제2
select pay_type, min(pay_amount) from payment p
group by pay_type
having min(pay_amount) >= 500;
#문제3
select serverno, count(distinct p.game_account_id) users_with_payment
from payment p
inner join users u on u.game_account_id = p.game_account_id
group by serverno
order by 1;
#문제4
select u.game_account_id,
count(distinct u.game_actor_id) actorcnt,
sum(p.pay_amount)
from users u
inner join payment p on u.game_account_id =p.game_account_id
where p.pay_type like "%CARD%" and u.serverno >= 2
group by 1
order by 3 desc;
#문제5
select game_account_id , `date` last_login_date , logid ,ip_addr , `date` ,game_actor_id
from users u
where (game_account_id , `date`) in
(select game_account_id , max(`date`)
from users
group by game_account_id)
order by 2 desc;
'SQL' 카테고리의 다른 글
[SQL 연습 문제 7] 랭크 게임 하다가 싸워서 피드백 남겼어요… (0) | 2024.06.18 |
---|---|
[SQL 연습 문제 6] 팀 프로젝트 열심히 했으니 다시 놀아볼까요?! (0) | 2024.06.18 |
[SQL 과제 LV. 3] 이용자의 포인트 조회하기 (0) | 2024.06.10 |
[SQL 과제 LV. 2] 날짜별 획득 포인트 조회하기 (0) | 2024.06.10 |
[SQL 과제 LV. 1] 데이터 속 김서방 찾기 (0) | 2024.06.10 |