When you're using count(), sum(), avg() with another field like data or ip you have to group your fields.

Something like that:

SELECT COUNT(*) as nrecords, ip, data FROM click WHERE a = XYZ GROUP BY data, ip;


Therefore you don't need to distinct your fields


I hope i understand your problems right.