Re: COUNT inside IF function returning wrong result
Joins can make aggregate results multiply as in the Sorcerer's Apprentice. Try moving the aggregation to a subquery eg ...
select u.user_id, m.N
from users u
left join (
select user_id, count(message_id) as N
from messages
group by user_id
) m using(user_id);
Subject
Written By
Posted
Re: COUNT inside IF function returning wrong result
June 22, 2015 09:08PM
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.