you applying count and distinct function together i don't think it will work for you
distinct function gives you one record for repeated records
and count function counts all the records in from a table.
you have to change your query otherwise you get error