Query: SELECT s.ip , COUNT(DISTINCT s.id) , COUNT(DISTINCT i.id) as TotalInputs , COUNT(DISTINCT i.input) as UniqInputs , COUNT(DISTINCT d.id) as files , COUNT(DISTINCT d.shasum) as Uniqfiles FROM sessions s LEFT JOIN input i ON s.id = i.session LEFT JOIN downloads d ON s.id = d.session GROUP BY s.ip; SQL Fiddle Output: ip | COUNT(DISTINCT s.id) | TotalInputs | UniqInputs | files | Uniqfiles IP2 | 1 | 3 | 2 | 1 | 1 IP3 | 3 | 5 | 4 | 3 | 2