query-66000011732637cb47d129300d30f0df
title:Query for common properties, their counts, and examples based on an identifier SELECT ?prop ?propLabel ?item_count ?stmt_count ?samp ?sampLabel ?valLabel
WITH {
SELECT ?prop (COUNT(DISTINCT ?item) AS ?item_count) (COUNT(DISTINCT ?stmt) AS ?stmt_count) (SAMPLE(?item) AS ?samp) (SAMPLE(?value) AS ?val) WHERE {
hint:Query hint:optimizer "None" .
?item wdt:P1795 ?yp_id . # select an identifer here
?item ?p ?stmt .
?prop wikibase:claim ?p .
?prop wikibase:statementProperty ?ps .
?stmt ?ps ?value .
} GROUP BY ?prop
} AS %counts
WHERE { INCLUDE %counts . MINUS { VALUES ?identifier {wd:Q19847637 wd:Q18614948} . # Wikidata property representing a unique identifier, Wikidata property for authority control ?prop wdt:P31/wdt:P279* ?identifier . }
?prop rdfs:label ?prop_label . FILTER(lang(?prop_label) = 'en') . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?item_count) DESC(?stmt_count)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Query for common properties, their counts, and examples based on an identifier
SELECT ?prop ?propLabel ?item_count ?stmt_count ?samp ?sampLabel ?valLabel
WHERE {
{
SELECT ?prop (COUNT(DISTINCT ?item) AS ?item_count) (COUNT(DISTINCT ?stmt) AS ?stmt_count) (SAMPLE(?item) AS ?samp) (SAMPLE(?value) AS ?val) WHERE {
?item wdt:P1795 ?yp_id . # select an identifer here
?item ?p ?stmt .
?prop wikibase:claim ?p .
?prop wikibase:statementProperty ?ps .
?stmt ?ps ?value .
} GROUP BY ?prop
}.
MINUS {
VALUES ?identifier {wd:Q19847637 wd:Q18614948} . # Wikidata property representing a unique identifier, Wikidata property for authority control
?prop wdt:P31/wdt:P279* ?identifier .
}
?prop rdfs:label ?prop_label . FILTER(lang(?prop_label) = 'en') .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?item_count) DESC(?stmt_count)