Use a correct query for different databases: you cannot use a clob in a distinct