query-66000011732637cb47d129300d30f0df

rq turtle/ttl

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

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)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v13("?identifier") v4("?item") v11("?item_count"):::projected v6("?p") v8("?prop"):::projected v3("?prop_label") v9("?ps") v11("?samp"):::projected v7("?stmt") v11("?stmt_count"):::projected v12("?val") v10("?value") v5("?yp_id") a1((" ")) c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?prop_label = 'en'"]] f0 --> v3 v4 --"wdt:P1795"--> v5 v4 -->v6--> v7 v8 --"wikibase:claim"--> v6 v8 --"wikibase:statementProperty"--> v9 v7 -->v9--> v10 bind5[/"count(?item)"/] v4 --o bind5 bind5 --as--o v11 bind6[/"count(?stmt)"/] v7 --o bind6 bind6 --as--o v11 bind7[/"sample(?item)"/] v4 --o bind7 bind7 --as--o v11 bind8[/"sample(?value)"/] v10 --o bind8 bind8 --as--o v12 subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; bind10[/VALUES ?identifier/] bind10-->v13 bind100(["wd:Q19847637"]) bind100 --> bind10 bind101(["wd:Q18614948"]) bind101 --> bind10 v8 --"wdt:P31"--> a1 a1 --"wdt:P279"--> v13 end v8 --"rdfs:label"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end