I have a table which looks like this:
from_user to_user type
43 85 1
32 43 2
64 79 1
77 43 4
54 43 5
13 96 4
78 43 6
I have a variable $user, and I need a query which returns the sum of from_user (i.e. how many from_users are there) where it equals $user, but only if type=1. If type=4 or 5, I need the sum of to_user where it equals $user. Is it possible to do this in one query?
Thanks in advance!