Querying: Difference between revisions

Line 77: Line 77:
  GROUP BY ?statusLabel
  GROUP BY ?statusLabel
  ORDER BY desc(?count)
  ORDER BY desc(?count)
===How many kazas between 1800 and 1900?===
Not working yet. Thanks to [https://stackoverflow.com/users/7879193/stanislav-kralin Stanislav Kralin] for [https://stackoverflow.com/questions/75137894/counting-items-over-time-using-sparql help]. [ run]
SELECT ?number (count(*) as ?count)  { 
?year ogt:P6 og:Q15677 ; ogt:P24 ?number
FILTER (?number >= 1800  && ?number <= 1900)
?kaza ogt:P15 og:Q3.
?kaza ogp:P15 ?statement.
?statement ogps:P15 og:Q3.
?statement ogpq:P7 ?starttime.
OPTIONAL{?statement ogpq:P8 ?endtime.}
OPTIONAL{?statement ogpq:P22 ?endtime.}
BIND (YEAR(?starttime) AS ?year1)
BIND (YEAR(COALESCE(?endtime, NOW())) AS ?year2)
FILTER (?number >= ?year1 && ?number <= ?year2)
}
group by ?number
order by ?number


== Federated query with Wikidata ==
== Federated query with Wikidata ==