2
I am selecting with case comparing different status of the same field and counting them in separate columns. The problem is that the first column is NULL
until the list of the second finishes counting. After that is reversed.
My query is the following:
select
case when cor.status = 35 then count(cor.uid) end as finalizadas,
case when cor.status = 50 then count(cor.uid) end as canceladas_motorista,
mot.nome || ' ' || mot.sobrenome as nome,
mot.celular,
mot.email
from motoristas mot, corridas cor
where...
follows example of result:
Some help, if you please?
"The problem is that the first column is NULL until the list of the second one finishes the count. Then this is reversed" John, I don’t understand, can you explain better? How to finish the count? The result comes all at once, I didn’t understand what you meant
– Ricardo Pontual
I adjusted the post there with a photo. I ended up not expressing myself correctly at first, but I think with the image will be easier to understand.
– João Jeefer Da Silva Félix
now yes understood :) you want in the same line finalized and canceled right?
– Ricardo Pontual
exactly! That’s the point. I’ll try to be more objective in the next
– João Jeefer Da Silva Félix
only one question, is not in your select, but joins are being done right? If not by
inner join
, you’re doing in thewhere
right? otherwise the result will go wrong– Ricardo Pontual
yes, I’m doing in the Where!
– João Jeefer Da Silva Félix