MySQL Forums
Forum List  »  Newbie

Re: Query with several evaluations on the same column
Posted by: Jörg Z
Date: June 28, 2016 06:15AM

@Peter
PS: I tried a bit other joins. It seems that the SQL
select
p.a,
sum( if(q.b=4,1,0) ) as 4count,
sum( if(q.b=5,1,0) ) as 5count,
sum( if(q.b=6,1,0) ) as 6count
from p left join q on (p.a = q.c)
group by p.a;

has the same result. Isn't it? Or is it accidentally? If it were correct, my problem is solved.

PPS: Not every markup code works [pre]for example not[/pre] ;-)

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.