Group result through a conditional

Asked

Viewed 64 times

2

I wonder if in Mysql or any other Bank you have the possibility to use GROUP BY with a conditional.

I will try to explain I have a status column that can have the value true and false, would like to group only when the value is true.

Thanks in advance.

1 answer

1


The clause HAVING can be used for this as an example below:

SELECT * FROM tabela 
GROUP BY status 
HAVING status = 'true'
  • worked, I need you to take me a doubt and in case I want to bring the false status, but not grouped would have as

  • SELECT * FROM table WHERE status = 'false'

  • I want to bring both false and true, but I want to group only the true has as??

Browser other questions tagged

You are not signed in. Login or sign up in order to post.