query-b54a0402680d7d6db630ff2034aa37fc
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
- https://query.wikidata.org/sparql
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