1
I have 2 tables:
FATHER:
id
nome
SON:
id
idpai
sexo_filho
I wanted to make a SELECT that adds up the amount of children male and female, that’s the problem, I can only do with one of the sex:
SELECT pai.nome, count(distinct filho.id) as somahomem
FROM pai
LEFT JOIN filho ON pai.id = filho.idpai AND conta_filho.sexo = 'm'
How to do with both sexes? Have the value of both?
Thanks, it’s going straight, there’s no way to put a distinct in it?
– caiocafardo
In that structure you informed, in my view, it is unnecessary the distinct as the result would be the same.
– Jean Gustavo Prates
So my query is more complex, it has several Count and sum with other tables. Without the distict I don’t know why it will multiply the Counts between them....
– caiocafardo
I updated with DISTINCT.
– Jean Gustavo Prates