I want a generic query to get fill rate of all columns in table .Query should work irrespective of the column number.I have to implement this using presto sql.I have tried searching for a method but nothing seems to working.
Input
A | B | C | D |
---|---|---|---|
1 | null | null | 1 |
2 | 2 | 3 | 4 |
Null | Null | Null | 5 |
Output
A | B | C | D |
---|---|---|---|
0.66 | 0.33 | 0.33 | 1.0 |
Explanation: A Col contains 3 rows with 2 non null values so 2/3 B and C Cols contain 2 null value and one non null value so 1/3 D col there is no null values so 3/3
Thanks in advance