Open Stevoisiak opened 1 year ago
CC @kaikalur
I'd like to take on this feature request 😀
I'd like to take on this feature request too.
Feel free to submit a PR!
hi @tdcmeehan is this still open can i work on this
@DHRUV6029 yes it's still open.
Feature Request
Implement a
SUM_IF(x, y)
aggregate function that would return the sum of TRUE input values. This would be equivalent toSUM(CASE WHEN x THEN y END)
Desired Functionality
Add a function similar to
COUNT_IF(x)
that would allow developers to simplify their code and improve readability of conditional sums.Example Usage
Take the following example of conditional sums:
Adding a
SUM_IF()
function would allow it to be rewritten as:Additional Information
The syntax could optionally allow for a third parameter
n
to allow specifying a fallback SUM value that would avoid NULL values. So for example,SUM_IF(condition, value, 0)
would be equivalent toSUM(CASE WHEN condition THEN value ELSE 0 END)
.