-
-
Save thinkjson/1563609 to your computer and use it in GitHub Desktop.
sample sql luciddb
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
| select 'Last 30 Days', sum(measure1) | |
| from time t, fact f | |
| where f.timeid = t.timeid | |
| and | |
| f.date between applib.add_days(current_date, -30) and current_date | |
| UNION ALL | |
| select 'Current Month', sum(measure1) | |
| from time t, fact f | |
| where f.timeid = t.timeid | |
| and t.month = applib.extract_timestamp(current_timestamp, 'MONTH')+1 | |
| and t.year = applib.extract_timestamp(current_timestamp, 'YEAR') | |
| UNION ALL | |
| select 'Previous Month', sum(measure1) | |
| from time t, fact f | |
| where f.timeid = t.timeid | |
| and t.month = applib.extract_timestamp( (current_timestamp - INTERVAL '1' month), 'MONTH')+1 | |
| and t.year = applib.extract_timestamp( (current_timestamp - INTERVAL '1' month), 'YEAR') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment