mysql if - how to apply to equal records

Asked

Viewed 54 times

2

Hello! staff I am trying to select and apply a rule only in equal records. I need all records to be listed, but in those that are equal, a specific rule is applied;

For example, select all client records, and in all that have the same codDeference, group and show only q has the non-blank;

I’m trying like this:

select * from clientes group by codDeReferencia where id in(select distinct codDeReferencia from clientes where dataAlteracao!='')
  • 1

    I suggest you put up some evidence so we can help you. So you suggest you can have a "group by + having" but without the data is difficult.. Creates a SQL Fiddle and shares

No answers

Browser other questions tagged

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