-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add aggregate function SUM_IF() #19060
Labels
Comments
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! |
6 tasks
hi @tdcmeehan is this still open can i work on this |
@DHRUV6029 yes it's still open. |
hello @tdcmeehan @Stevoisiak @ges1227 I have submitted the pr #19060 for this feature can you please review it please. thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)
.The text was updated successfully, but these errors were encountered: