0

I have a table like this

id status
1  Pass
2  Fail
3  Pass

How can I count total rows and rows where status is "Fail" with their id(s) by group_concat in one select query. I am trying to get output like this

total group_concat(id)
3     1,2,3
1     2

Any advice?

1 Answer 1

1

you'll need to union two separate queries:

select status,
       count(*) as num,
       group_concat(id) as ids
from tests as status_stats
union all
select null as status,
       count(*) as num,
       group_concat(id) as ids
from tests as total_stats
Sign up to request clarification or add additional context in comments.

Comments

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.