query-0dcb206e7945cebbda4e3088326fe5eb

rq turtle/ttl

g. # relations

currently properties. Could be expanded to other

SELECT (COUNT(DISTINCT ?wdt) as ?nb_relations) WITH { SELECT DISTINCT ?item WHERE { ?item wdt:P279* wd:Q181388 . # ?item wdt:P641 wd:Q847 .

}

} as %a { INCLUDE %a ?p wikibase:directClaim ?wdt . { ?item ?wdt [] } UNION { [] ?wdt ?item } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#  g. # relations
# currently properties. Could be expanded to other

SELECT (COUNT(DISTINCT ?wdt) as ?nb_relations) 
{

{
    SELECT DISTINCT ?item
    WHERE
    {
        ?item wdt:P279* wd:Q181388 .
     #  ?item wdt:P641 wd:Q847 .

    }      
}
  ?p wikibase:directClaim ?wdt .
  { ?item ?wdt [] } UNION { [] ?wdt ?item }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item") v4("?nb_relations") v2("?p") v3("?wdt"):::projected a1((" ")) a2((" ")) c2(["wd:Q181388"]):::iri v1 --"wdt:P279"--> c2 v2 --"wikibase:directClaim"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a2 -->v3--> v1 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 -->v3--> a1 end union0r <== or ==> union0l end bind1[/"count(?wdt)"/] v3 --o bind1 bind1 --as--o v4