6.2.7 The #:distinct clause
The #:distinct clause allows you to filter query
the results for unique results. It is the equivalent of the DISTINCT
or DISTINCT ON clauses in SQL.
Tor consistent results across all DBMSs, the query must be sorted such that rows are returned in a deterministic order, with similar rows adjacent to one another in the result set.
The #:distinct clause may be one of the following values:
#:distinct #t dictates that rows should be completely unique - the equivalent of writing "SELECT DISTINCT foo" in SQL:
; (listof string) ; The surnames of people in the database: ; one result per distinct surname. (find-all (sql (select #:what person.surname #:from person #:distinct #t))) #:distinct #f completely disables uniqueness checking - the equivalent of writing SElECT foo or SELECT ALL foo in SQL:
; (listof string) ; The surnames of people in the database: ; one result per person. (find-all (sql (select #:what person.surname #:from person #:distinct #f))) #:distinct (expr ...) enables uniqueness checking with a custom uniqueness rule. Two results are considered equal if all exprs return the same values:
; (listof (list string string)) ; The surnames of people in the database, ; one result per distinct surname, ; together with the forenames of the first ; person found with each surname: (find-all (sql (select #:what (person.surname person.fornames) #:from person #:distinct (person.surname))))