Only want unique records.

  • I have a customer support database that manages incidents and responses. For the customer, I get the list of incidents that have been touched by support using the following SQL

    SELECT incidents.*

    FROM incidents INNER JOIN responses ON incidents.incidentid = responses.incident

    WHERE (((responses.replydate)>[incidents].[dateaccessed]) AND ((responses.incident)=[incidents].[incidentid]) AND ((incidents.userid)=) AND ((incidents.closed)=0));

    This gives me almost what I want but if for instance incident 2 has had 2 replies from support it gets listed in the results twice, once for each of the two replies.

    I just want to say to the user that incident 1,2,5 and 7 have been replied to. How do I remove the duplicates?

    Thanks for your help.

  • Sorry for the white noise. Fixed it myself.

    SELECT DISTINCT incidents.*

    FROM incidents INNER JOIN responses ON incidents.incidentid = responses.incident

    WHERE (((responses.replydate)>[incidents].[dateaccessed]) AND ((responses.incident)=[incidents].[incidentid]) AND ((incidents.userid)=) AND ((incidents.closed)=0));

    too simple really...

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply