-
Notifications
You must be signed in to change notification settings - Fork 14
/
common.sql
26 lines (22 loc) · 820 Bytes
/
common.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
select
(`bill/BillingPeriodStartDate` || "-" || `bill/BillingPeriodEndDate`) as `period`,
`product/ProductName` as `product`,
COALESCE(`lineItem/Operation`, "") as `operation`,
`lineItem/LineItemType` as `item_type`,
COALESCE(`product/usagetype`, "") as `usage_type`,
COALESCE(`pricing/unit`, "") as `usage_unit`,
SUM(`lineItem/UsageAmount`) as metric_amount,
SUM(`lineItem/UnblendedCost`) as metric_cost,
`lineItem/CurrencyCode` as `currency`
from `report-current.csv`
where `lineItem/UnblendedCost` > 0
group by
`bill/BillingPeriodStartDate`,
`bill/BillingPeriodEndDate`,
`product/ProductName`,
`lineItem/Operation`,
`lineItem/LineItemType`,
`product/usagetype`,
`pricing/unit`,
`lineItem/CurrencyCode`
order by `period`, `product`, `operation`