Last active
March 25, 2023 19:30
-
-
Save ANelson82/ebc55a183fa435eded58a15ba5a8c004 to your computer and use it in GitHub Desktop.
Boilerplate EDA 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
| with cte1 as ( | |
| select | |
| quantile_cont(amount, [.01, .10, .25, .5, .75, .9, .99]) as p | |
| , min(amount) as min | |
| , max(amount) as max | |
| , mode(amount) as mode | |
| , (select count(amount) from MY_TABLE where amount = 0) as zeroes_cnt | |
| , (select count(amount) from MY_TABLE where amount is null) as null_cnt | |
| , (select count(amount) from MY_TABLE) as total_cnt | |
| from MY_TABLE) | |
| select | |
| cte1.p[1] as p01 | |
| , cte1.p[2] as p10 | |
| , cte1.p[3] as p25 | |
| , cte1.p[4] as p50 | |
| , cte1.p[5] as p75 | |
| , cte1.p[6] as p90 | |
| , cte1.p[7] as p99 | |
| , cte1.min | |
| , cte1.max | |
| , cte1.mode | |
| , cte1.zeroes_cnt | |
| , cte1.null_cnt | |
| , cte1.total_cnt | |
| from cte1 | |
| # p01 p10 p25 p50 p75 p90 p99 min max mode median zeroes_cnt null_cnt total_cnt | |
| # thanks Hawkfish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment