Querying: Difference between revisions

(→‎Sample queries: kaza count per year)
Line 58: Line 58:
  }
  }
  GROUP BY ?year
  GROUP BY ?year
ORDER BY desc(?count)
===Count status types in a given year===
For a given year, how many regions of each status are found in the dataset? [https://tinyurl.com/2mqqhl8u run]
SELECT (COUNT (DISTINCT ?region) AS ?count) ?statusLabel
WHERE
{
  ?region ogp:P15 ?statement.
  ?statement ogps:P15 ?status.
  ?statement ogpq:P7 ?starttime.
  OPTIONAL{?statement ogpq:P8 ?endtime.}
  OPTIONAL{?statement ogpq:P22 ?endtime.}
  #enter same year twice
  FILTER(YEAR(?starttime) <= 1600 && YEAR(?endtime) > 1600)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
GROUP BY ?statusLabel
  ORDER BY desc(?count)
  ORDER BY desc(?count)