Project:SPARQL/examples: Difference between revisions

From Chemical Compounds of Interest
Jump to navigation Jump to search
m (Egonw moved page Project:SPARQL/Examples to Project:SPARQL/examples over redirect)
 
(No difference)

Latest revision as of 15:49, 7 August 2024

Compound Lists

The VHP4Safety compounds

PREFIX wd: <https://compoundcloud.wikibase.cloud/entity/>
PREFIX wdt: <https://compoundcloud.wikibase.cloud/prop/direct/>

SELECT ?cmp ?cmpLabel ?typeLabel ?pubchem ?cas ?wikidata ?toxbank
       (GROUP_CONCAT(DISTINCT ?roleLabel; separator=", ") AS ?roles)
WHERE {
  ?cmp wdt:P21 wd:Q2059 ; wdt:P1 ?type .
  OPTIONAL { ?cmp wdt:P13 ?pubchem }
  OPTIONAL { ?cmp wdt:P4 ?toxbank }
  OPTIONAL { ?cmp wdt:P5 ?wikidata }
  OPTIONAL { ?cmp wdt:P23 ?cas }
  OPTIONAL { ?cmp wdt:P17 ?role . ?role rdfs:label ?roleLabel }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?typeLabel ?cmp ?cmpLabel ?pubchem ?wikidata ?toxbank ?cas

Try it!