query-c109f17a9a62dd0f874f718afb9bc857

rq turtle/ttl

SPARQL sandbox

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?sample ?sampleLabel ?property ?propertyLabel ?qualifiers ?statements WHERE {
  {
    SELECT DISTINCT ?p ?qualifiers (SAMPLE(?item) AS ?sample) (COUNT(?stmt) AS ?statements) WHERE {
      {
        SELECT ?item ?p ?stmt (GROUP_CONCAT(?kv) AS ?qualifiers) WHERE {
          {
            SELECT ?item ?p ?stmt ?str ?kv WHERE {
              {
                SELECT ?item ?p ?stmt ?str (COUNT(?qval) AS ?values) WHERE {
                  VALUES ?p {p:P1359}
                  ?item ?p ?stmt .
                  #?stmt pq:P642 ?qval0 .
                  ?stmt ?pq ?qval .
                  ?wdq wikibase:qualifier ?pq .
                  BIND(STRAFTER(STR(?pq), "/P") AS ?str)
                }
                GROUP BY ?item ?p ?stmt ?str
              }
              BIND(CONCAT(?str, ":", STR(?values)) AS ?kv)
            }
            ORDER BY DESC(STRLEN(?str)) DESC(?str) ?kv ?stmt ?p
          }
        }
        GROUP BY ?item ?p ?stmt
      }
    }
    GROUP BY ?p ?qualifiers
  }
  ?property wikibase:claim ?p .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?property DESC(?statements)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?item") v12("?kv") v7("?p") v8("?pq") v1("?property"):::projected v12("?qualifiers"):::projected v9("?qval") v13("?sample"):::projected v14("?statements"):::projected v5("?stmt") v11("?str") v11("?values") v10("?wdq") c4(["bd:serviceParam"]):::iri c6(["en"]):::literal bind0[/VALUES ?p/] bind0-->v7 bind00(["p:P1359"]) bind00 --> bind0 v7 -->v7--> v5 v5 -->v8--> v9 v10 --"wikibase:qualifier"--> v8 bind1[/"substring-after(str(?pq),'/P')"/] v8 --o bind1 bind1 --as--o v11 bind3[/"count(?qval)"/] v9 --o bind3 bind3 --as--o v11 bind4[/"concat(?str,':',str(?values))"/] v11 --o bind4 v11 --o bind4 bind4 --as--o v12 bind6[/"?kv"/] v12 --o bind6 bind6 --as--o v12 bind9[/"sample(?item)"/] v7 --o bind9 bind9 --as--o v13 bind10[/"count(?stmt)"/] v5 --o bind10 bind10 --as--o v14 v1 --"wikibase:claim"--> v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c4 --"wikibase:language"--> c6 end