본문 바로가기
Mysql

mysql sum if 사용

by NaHyungMin 2018. 10. 2.

아이템 구매 일자별로 통계 확인


1
2
3
4
5
6
7
8
9
SELECT date(`create_time`) as `create_time`
    , sum(if(`reward_type` = 310)) as `heart_count`
    , sum(if(`reward_type` = 5 and `item_type` = 110)) as `straight_line`
    , sum(if(`reward_type` = 5 and `item_type` = 210)) as `range`
    , sum(if(`reward_type` = 5 and `item_type` = 310)) as `choice`
    , sum(if(`reward_type` = 5 and `item_type` = 410)) as `one_block`
    , sum(if(`reward_type` = 5 and `item_type` = 510)) as `shuffle`
FROM `statistics_buy_shop`
group by date(`create_time`);



cs


'Mysql' 카테고리의 다른 글

기본 오류 처리  (0) 2018.10.12
저장소 특징  (0) 2018.10.12
접속자 통계  (0) 2018.09.13
mysql 게임 서버 MAU 처리  (0) 2018.06.20
mysql 스케줄러 사용  (0) 2018.06.20