Created
November 2, 2017 04:11
-
-
Save woosungchu/f8a586ff64ae305f673fa0ed396c7cfb to your computer and use it in GitHub Desktop.
payLaterHistoryInfo.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# U = USE , R = REFUND, amount = eachPrice | |
select | |
ifnull(sum(a.sms),0) as smsSize | |
,ifnull(sum(a.lms),0) as lmsSize | |
,ifnull(sum(a.mms),0) as mmsSize | |
,ifnull(sum(a.amount),0) as totalPrice | |
from ( | |
select | |
case when message_type = 'SMS' then ( case when gubun = 'U' then 1 else -1 end) else 0 end as sms | |
,case when message_type = 'LMS' then ( case when gubun = 'U' then 1 else -1 end) else 0 end as lms | |
,case when message_type = 'MMS' then ( case when gubun = 'U' then 1 else -1 end) else 0 end as mms | |
,case when gubun = 'U' then amount else -amount end as amount | |
from SMS_HISTORY_TABLE | |
where tenant_id = #{tenantId} | |
and message_type in ('SMS','LMS','MMS') | |
and gubun in ('N','U') | |
and MONTH(action_date) = #{month} | |
) a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment