query with group function gives error " Invalid use of group function" : I have 3 tables:
users table: contains the userid, email, contact no
like table:which contains picture ids, and userids who liked it
picture posted table: which conatins picture ids, user id who posted it
 I want to get the no of likes each user got from the above tables:
I am using the below query , it is giving an error , what would be the correct one :

    select sum(count(pid)) from p_like where pid in (
        select pid from p_picuser where userid in (
            SELECT userid from p_users 
            )
        ) GROUP BY pid