Querying: Difference between revisions

Line 81: Line 81:
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]
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) {  
  PREFIX og: <https://ottgaz.org/entity/>
  ?year ogt:P6 og:Q15677 ; ogt:P24 ?number
  PREFIX ogs: <https://ottgaz.org/entity/statement/>
  FILTER (?number >= 1800 && ?number <= 1900)
  PREFIX ogv: <https://ottgaz.org/value/>
  PREFIX ogt: <https://ottgaz.org/prop/direct/>
PREFIX ogp: <https://ottgaz.org/prop/>
PREFIX ogps: <https://ottgaz.org/prop/statement/>
PREFIX ogpq: <https://ottgaz.org/prop/qualifier/>
PREFIX wd: <http://www.wikidata.org/entity/>
  PREFIX wdt: <http://www.wikidata.org/prop/direct/>
  SELECT ?number (count(*) as ?count) {
  ?kaza ogt:P15 og:Q3.
  ?kaza ogt:P15 og:Q3.
  ?kaza ogp:P15 ?statement.
  ?kaza ogp:P15 ?statement.
Line 90: Line 97:
  OPTIONAL{?statement ogpq:P8 ?endtime.}
  OPTIONAL{?statement ogpq:P8 ?endtime.}
  OPTIONAL{?statement ogpq:P22 ?endtime.}
  OPTIONAL{?statement ogpq:P22 ?endtime.}
    SERVICE <https://query.wikidata.org/sparql> {
?year wdt:P6 wd:Q15677 ; wdt:P24 ?number .
  }
  BIND (YEAR(?starttime) AS ?year1)
  BIND (YEAR(?starttime) AS ?year1)
  BIND (YEAR(COALESCE(?endtime, NOW())) AS ?year2)
  BIND (YEAR(COALESCE(?endtime, NOW())) AS ?year2)
FILTER (?number >= 1800  && ?number <= 1900)
  FILTER (?number >= ?year1 && ?number <= ?year2)
  FILTER (?number >= ?year1 && ?number <= ?year2)
  }  
  }
  group by ?number
  group by ?number
  order by ?number
  order by ?number