Querying: Difference between revisions

Line 27: Line 27:
  }
  }


=== Start and end dates ===
=== Duration, start and end dates ===
Every region with a start date, as well as end/latest dates where supplied. [https://tinyurl.com/2gn56lb4 run]
Duration between start and end date of every region with a start date, as well as region type. [https://tinyurl.com/2k8h75bz run]


PREFIX og: <https://ottgaz.org/entity/>
PREFIX ogs: <https://ottgaz.org/entity/statement/>
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 ogpq: <https://ottgaz.org/prop/qualifier/>
SELECT ?regionLabel ?statusLabel (YEAR(?starttime) as ?start) (YEAR(?endtime) as ?end) ?duration
WHERE
{
  ?region ogt:P6 og:Q1.
  ?region ogp:P15 ?statement.
  ?statement ogps:P15 ?status.
  ?statement ogpq:P7 ?starttime.
  OPTIONAL{?statement ogpq:P8 ?endtime.}
  OPTIONAL{?statement ogpq:P22 ?endtime.}
  BIND(year(?endtime)-year(?starttime) as ?duration )
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY desc(?duration)


  SELECT ?regionLabel ?statusLabel ?starttime ?endtime
  SELECT ?regionLabel ?statusLabel ?starttime ?endtime