WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

SPARQLDistinct[]

is a query operator that deletes duplicate solutions.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Properties & Relations  
See Also
Related Guides
Cite this Page

SPARQLDistinct[]

is a query operator that deletes duplicate solutions.

Details and Options

  • A RightComposition of operators SPARQLSelect []/*/*SPARQLDistinct[]/* can be used in SPARQLExecute to query a SPARQL endpoint. Composition is also supported.
  • SPARQLDistinct[] can be applied to the result of a SPARQLSelect query.
  • Solutions are represented as associations.
  • SPARQLDistinct[] treats associations that differ only in the order of their keys as the same.

Examples

open all close all

Basic Examples  (1)

Wolfram Language code: Needs["GraphStore`"]

Data about people:

Wolfram Language code: people = GraphStore`RDFStore[{GraphStore`RDFTriple[URL["http://example.org/bobSmith"], URL["http://xmlns.com/foaf/0.1/name"], "bob"], GraphStore`RDFTriple[ URL["http://example.org/bobTaylor"], URL["http://xmlns.com/foaf/0.1/name"], "bob"], GraphStore`RDFTriple[URL["http://example.org/annaWatson"], URL["http://xmlns.com/foaf/0.1/name"], "anna"]}, Association[]];

Find distinct names:

Wolfram Language code: select = SPARQLSelect[RDFTriple[RDFBlankNode[], URL["http://xmlns.com/foaf/0.1/name"], SPARQLVariable["name"]]];
Wolfram Language code: people//SPARQLQuery[select /* SPARQLDistinct[]]

Count the occurrences of each name:

Wolfram Language code: people//SPARQLQuery[ select /* SPARQLAggregate[ {"name", "count" -> SPARQLEvaluation["count"][]}, SPARQLVariable["name"] ] ]

Properties & Relations  (1)

Wolfram Language code: Needs["GraphStore`"]

The first two associations differ only in the order of their keys:

Wolfram Language code: data = { <|"x" -> 1, "y" -> "a"|>, <|"y" -> "a", "x" -> 1|>, <|"x" -> 2, "y" -> "b"|> };

DeleteDuplicates treats associations with keys in a different order as different:

Wolfram Language code: data//DeleteDuplicates

For SPARQLDistinct the order of keys does not matter:

Wolfram Language code: data//SPARQLDistinct[]

This gives the same result:

Wolfram Language code: data//DeleteDuplicatesBy[KeySort]
Wolfram Language code: %% == %
Wolfram Research (2020), SPARQLDistinct, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html.

Text

Wolfram Research (2020), SPARQLDistinct, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html.

CMS

Wolfram Language. 2020. "SPARQLDistinct." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html.

APA

Wolfram Language. (2020). SPARQLDistinct. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html

BibTeX

@misc{reference.wolfram_2026_sparqldistinct, author="Wolfram Research", title="{SPARQLDistinct}", year="2020", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html}", note=[Accessed: 16-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_sparqldistinct, organization={Wolfram Research}, title={SPARQLDistinct}, year={2020}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html}, note=[Accessed: 16-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /