-1
I am making a query to my database, where it returns me several lines and groups so that I am shown only one. However, there is a column called "validated", with most values defined as "Yes". I would like if there was at least 1 "No" value, it points the "validated" column in GROUP BY to "No" as well.
SELECT assessor,
broker,
cod_cliente,
data_compra,
data_inicial,
id,
nome_cliente,
papel,
preco,
quantidade,
squad,
validado
FROM carteira_perspectiva
WHERE (broker = "Eric")
GROUP BY cod_cliente
I don’t understand well, but if you want to do a "group by conditional" this is not possible
– Ricardo Pontual
It would be if at least one of the group values is "No", it brings this values. Or else prioritize the values "No". Do you think it is not possible then?
– Eric Vinicius
It was not very clear, but from what I could imagine you would have to use the CASE statement with a condition that evaluates the client code and if there is a record "No" it replicates "No" to all the respective records of that client. That way when you group it will demonstrate "Not validated" because there was one or more "Not" records for that cod_client.
– Bruno_Cassiano
I’m not getting it.. Can you write what the code would look like? But that’s exactly what it would be like!
– Eric Vinicius