I need to return as many fields as 0 each record has and rank the one with the zeros down. Example:
id | col2 | col3 | col4
1 | 1 | 0 | 0
2 | 0 | 0 | 0
3 | 0 | 1 | 4
4 | 0 | 3 | 5
5 | 3 | 2 | 40
The return in this case should be:
id | count(0)
5 | 0
3 | 1
4 | 1
1 | 2
2 | 3