query-b54a0402680d7d6db630ff2034aa37fc

rq turtle/ttl

Alternative version of the query using MAX()

German Vereine (Nonprofit Organisations) by Revenue

SELECT ?OrgaLabel ?Revenue (YEAR(?Renevue_time) AS ?year) ?ValutaLabel ?rank WHERE { { SELECT ?Orga (MAX(?time) AS ?Latest_time) WHERE { ?Orga wdt:P1454 wd:Q9299236 . # Select German Nonprofit Organisations ?Orga p:P2139/pq:P585 ?time . } GROUP BY ?Orga } ?Orga p:P2139 ?Revenue_statement . ?Revenue_statement pq:P585 ?Renevue_time . FILTER(?Renevue_time = ?Latest_time) ?Revenue_statement psv:P2139 ?Renevue_value . ?Renevue_value wikibase:quantityAmount ?Revenue . ?Renevue_value wikibase:quantityUnit ?Valuta . ?Revenue_statement wikibase:rank ?rank . SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en".} }

ORDER BY DESC(?Revenue) LIMIT 500

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Alternative version of the query using MAX()
#German Vereine (Nonprofit Organisations) by Revenue
SELECT ?OrgaLabel ?Revenue (YEAR(?Renevue_time) AS ?year) ?ValutaLabel ?rank
WHERE 
{
  {
    SELECT ?Orga (MAX(?time) AS ?Latest_time)
    WHERE
    {
      ?Orga wdt:P1454 wd:Q9299236 . # Select German Nonprofit Organisations
      ?Orga p:P2139/pq:P585 ?time .
    }
    GROUP BY ?Orga
  }
  ?Orga p:P2139 ?Revenue_statement .
  ?Revenue_statement pq:P585 ?Renevue_time .
  FILTER(?Renevue_time = ?Latest_time)
  ?Revenue_statement psv:P2139 ?Renevue_value .
  ?Renevue_value wikibase:quantityAmount ?Revenue .
  ?Renevue_value wikibase:quantityUnit ?Valuta .
  ?Revenue_statement wikibase:rank ?rank .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en".}
}

ORDER BY DESC(?Revenue)
LIMIT 500

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?Latest_time") v4("?Orga") v2("?Renevue_time"):::projected v7("?Renevue_value") v1("?Revenue"):::projected v6("?Revenue_statement") v8("?Valuta") v9("?rank"):::projected v5("?time") v10("?year") a1((" ")) c10(["bd:serviceParam"]):::iri c2(["wd:Q9299236"]):::iri c12(["de,en"]):::literal f0[["?Renevue_time = ?Latest_time"]] f0 --> v2 f0 --> v6 v4 --"p:direct/P1454"--> c2 v4 --"p:P2139"--> a1 a1 --"p:qualifier/P585"--> v5 bind2[/"max(?time)"/] v5 --o bind2 bind2 --as--o v6 v4 --"p:P2139"--> v6 v6 --"p:qualifier/P585"--> v2 v6 --"p:statement/value/P2139"--> v7 v7 --"wikibase:quantityAmount"--> v1 v7 --"wikibase:quantityUnit"--> v8 v6 --"wikibase:rank"--> v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind3[/"year-from-dateTime(?Renevue_time)"/] v2 --o bind3 bind3 --as--o v10