I have 3 tables (Incident, phonecallevent, eventreason)
The incident table stores all the information related to an incident and the ponecallevent table stores the information regarding the calls made to report incidents. The problem is that for one incident there may be several calls, to give you a small example of what I currently need I have this query: (UID: Incident / Name: Reason for call)
SELECT DISTINCT inc.uid, er.Name
FROM [Incident] Inc INNER JOIN
[PhoneCallEvent] PCE ON PCE.IncidentRefs = INC.GID INNER JOIN
[EventReason] ER ON ER.GID = PCE.eventReasonGID
Example result:
UID | NAME |
---|---|
INC 15128238 | Without energy |
INC 15128237 | Without energy |
INC 15128248 | Intermittent service |
INC 15128248 | Existence of Danger |
INC 15128248 | Without energy |
The problem is that the incident INC 15128248 has 3 calls and in all 3 of them a different reason was reported. In those cases in which there is more than one reason for an incident, I need to show only the first one and avoid repeating the incident several times .
The result should look like this:
UID | NAME |
---|---|
INC 15128238 | Without energy |
INC 15128237 | Without energy |
INC 15128248 | Intermittent service |
Any ideas?