Skip to content

Instantly share code, notes, and snippets.

@zachcp
Last active December 8, 2019 16:09
Show Gist options
  • Save zachcp/57e9378fa246e219855cc5dd7944ee9f to your computer and use it in GitHub Desktop.
Save zachcp/57e9378fa246e219855cc5dd7944ee9f to your computer and use it in GitHub Desktop.
Some WikiData Queries
SELECT (COUNT(*) as ?agg)
WHERE {
SELECT (COUNT(*) as ?count)
WHERE {
?item wdt:P235 ?inchi .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
GROUP BY ?item
HAVING( COUNT(?inchi) > 1)
LIMIT 1000
}
SELECT ?item
(COUNT(?inchi) AS ?inchicount)
(COUNT(DISTINCT ?inchi) AS ?uniqueinchicount)
(GROUP_CONCAT(DISTINCT ?inchi; SEPARATOR=", ") AS ?subjectLabels)
WHERE {
?item wdt:P235 ?inchi .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
GROUP BY ?item
HAVING( COUNT(?inchi) > 1 && COUNT(DISTINCT ?inchi) > 1)
LIMIT 250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment