Created
August 13, 2019 00:44
-
-
Save kleong/5f2b2b87e9c844be1bb3925d902f53f9 to your computer and use it in GitHub Desktop.
This file contains 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
> with details as ( | |
select tokenize(REGEXP_EXTRACT(text, 'Statement Date: .*'))[3] as month, | |
tokenize(REGEXP_EXTRACT(text, 'Statement Date: .*'))[5] as year, | |
cast(tokenize(REGEXP_EXTRACT(text, 'Total Amount Due:\n.*\nAmount Enclosed'))[4] as float) as amount | |
from "elec-bills" | |
) | |
select concat(month, '/', year) as billing_period, amount | |
from details | |
order by year asc, month; | |
+----------+------------------+ | |
| amount | billing_period | | |
|----------+------------------| | |
| 47.55 | 04/2018 | | |
| 76.5 | 05/2018 | | |
| 52.28 | 06/2018 | | |
| 50.58 | 07/2018 | | |
| 47.62 | 08/2018 | | |
| 39.7 | 09/2018 | | |
| <null> | 10/2018 | | |
| 72.93 | 11/2018 | | |
| 157.57 | 12/2018 | | |
+----------+------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment