query-939e5c307bc7d15fdaaf8261b1d8ce3c

rq turtle/ttl

e. median outgoing edges: number of outgoing edges

after the below, calculate median on ?nb_outgoing_edges

alternative method: include external id properties

SELECT ?item (COUNT(?wdt) as ?nb_outgoing_edges) WITH { SELECT DISTINCT ?item WHERE { ?item wdt:P279* wd:Q181388 . # ?item wdt:P641 wd:Q847 . }
} as %a { INCLUDE %a ?p wikibase:directClaim ?wdt ; wikibase:propertyType wikibase:WikibaseItem . ?item ?wdt [] } GROUP BY ?item

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#  e. median outgoing edges: number of outgoing edges
# after the below, calculate median on ?nb_outgoing_edges
# alternative method: include external id properties
SELECT ?item (COUNT(?wdt) as ?nb_outgoing_edges) 
{

{
    SELECT DISTINCT ?item
    WHERE
    {
        ?item wdt:P279* wd:Q181388 .
     # ?item wdt:P641 wd:Q847 .
    }      
}
  ?p wikibase:directClaim ?wdt ; wikibase:propertyType wikibase:WikibaseItem .
  ?item ?wdt []
}
GROUP BY ?item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v4("?nb_outgoing_edges") v2("?p") v3("?wdt"):::projected a1((" ")) c2(["wd:Q181388"]):::iri c5(["wikibase:WikibaseItem"]):::iri v1 --"wdt:P279"--> c2 v2 --"wikibase:directClaim"--> v3 v2 --"wikibase:propertyType"--> c5 v1 -->v3--> a1 bind1[/"count(?wdt)"/] v3 --o bind1 bind1 --as--o v4