Subject Cannot use distinct together with subselect
Author Florian Hector
I have a query with an embedded subselect.

Table TABKOMMUNIKATION contains unique communication details
Table tabKomart represents kind of communikation like phone, eMail, fax ...
Table TABUSERXKOMMUNIKATION is an n:m table assigning communication details
to persons
Server is Firebird 1.0.3

SELECT TABKOMMUNIKATION.KOMMID
, KOMARTID
, (Select KomArtDesc from tabKomart where
tabKommunikation.KomArtID=tabKomArt.KomArtID) AS Art
, KOMMDETAIL
, KOMMREMARK
FROM TABKOMMUNIKATION
JOIN TABUSERXKOMMUNIKATION ON
TABKOMMUNIKATION.KOMMID=TABUSERXKOMMUNIKATION.KOMMID
Where Exists
(Select Distinct KommID from TABUSERXKOMMUNIKATION Where PersID<> :PersID)

This gives me all entires in a table except the ones which are already
assigned to the currently selected Person.
It is possible, that entries are assigned to more than one person so I get
multiple lines of the same entry.
So I tried to to put a Distinct right after the first Select in order to get
unique lines, but then I get the following error.

Invalid token.
invalid request BLR at offset 185.
context already in use (BLR error).

However, it does work with the distinct when the first subselect is removed.

What can I do to get this working with the subselect?

Florian