0

At present, I have something like:

select sum(total) from table_name where field != ''
UNION
select sum(total) from table_name where field = ''

It works but I'm curious if it is possible to use "group by" to filter by empty and non-empty values?

1 Answer 1

1
select SUM(CASE WHEN field != '' THEN total ELSE 0) NONEMPTY,
       SUM(CASE WHEN field = '' THEN total ELSE 0) EMPTY from table_name

Try above query.

Here i had used CASE WHEN.

Sign up to request clarification or add additional context in comments.

3 Comments

I cannot see GROUP BY here
Well, the question is very specific
Yes, you're not answering the question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.