query-7308eac0a9226303bc22d6bfb4ca8e13
Battles per year per country last 80 years Battles per year per country last 80 years Batailles par année et par pays sur ces 80 dernières années Battles per year per country last 80 years Battles per year per country last 80 years Oorlogen per jaar per land de afgelopen 80 jaar Slag per år per land de senaste 80 åren Battles per year per country last 80 years Battles per year per country last 80 years Battles per year per country last 80 years
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:BarChart
SELECT(SAMPLE(?year) AS ?year) (COUNT(?_country) AS ?battles) (SAMPLE(?_countryLabel) AS ?_countryLabel) WHERE {
?subj wdt:P31 wd:Q178561. # instance of battle
OPTIONAL { ?subj wdt:P580 ?d1. } # start time
OPTIONAL { ?subj wdt:P585 ?d2. } # point in time
OPTIONAL { ?subj wdt:P582 ?d3. } # end time
BIND(IF(!BOUND(?d1), IF(!BOUND(?d2), ?d3, ?d2), ?d1) AS ?date)
BIND(STR(YEAR(?date)) AS ?year)
FILTER(BOUND(?year))
?subj wdt:P276/wdt:P17 ?_country. # country of location of battle
BIND((NOW()) - ?date AS ?distance)
FILTER((0 <= ?distance) && (?distance < 31 * 12 * 80))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?_country rdfs:label ?_countryLabel.}
}
GROUP BY ?year ?_country
ORDER BY ?_countryLabel
Query found at
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/en
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/es
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/fr
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/hy
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/ja
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/nl
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/sv
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/tr
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/uk
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced/zh