Added missing DISTINCT to host and service problem queries.

Fixing duplication on filtering and credentials.

Fixes #5020