Ik heb een probleempje met dat fantastische
crystal reports, hoe krijg je voor elkaar dat je een select distinct op een tabel kan uitvoeren, en liefst zonder een "SQL Expression" te gebruiken.
Crystal had zelf ook een oplossing maar die is zo lelijk dat ik hem weiger te gebruiken (plus dat ik het liefste geen "SQL Expression" wil.)
Crystal had zelf ook een oplossing maar die is zo lelijk dat ik hem weiger te gebruiken (plus dat ik het liefste geen "SQL Expression" wil.)
Solution:
Crystal Reports forbids changing only the first SELECT clause in the SQL
It does allow you to add another SELECT clause.
Here is a way to get Crystal Reports to do a SELECT DISTINCT:
1. Copy the entire SQL statement of the report and duplicate it.
Add a 'UNION' clause between the 2 SQL statements.
2. Modify the WHERE clause of the first SQL to say 'WHERE 0=1'.
If the SQL does not have a WHERE clause, add one. 'WHERE 0=1' makes the
first SQL a dummy SQL that does not select any records.
3. Modify the second SQL to read 'SELECT DISTINCT'. Since this
is the second SELECT statement in the SQL, Crystal Reports will allow
you to modify it and add the 'DISTINCT' word.
The final SQL should be like:
SELECT
<field list>
FROM
<table lis>
WHERE
0=1
UNION
SELECT DISTINCT
<field list>
FROM
<table list>
WHERE
<record criteria>