query-d4de5632db3671d5deaa513bab5006fb
10:35, 18 March 2019 (UTC)) talk (BouzinacThanks. pagetalk / TomT0m author : It makes the queries uselessly complicated. There are two ways to express the number is a total number : either no qualifier at all or a « whole » value … I’d prefer a « total number » property for example, this would make the query a lot simpler. That’s why I think it’s a bad design decision … Tagishsimon@ 11:19, 18 March 2019 (UTC)) talk (Tagishsimon --goes off Tomt0m somewhat. or has no applied to qualifier. (Q2165236)everything What's wrong with my applies to pattern, Tom? How would you do it differently? Given Bouzinac's spec, it seemed an effective solution to identify whether the patronage statement applied to It doesn't work because the Patronage statements have no pq:P585 qualifiers. You'd need to make the ?time business optional to get AMM to work. 10:58, 18 March 2019 (UTC) pagetalk / TomT0m author I don’t know but the « applies to : whole » pattern is really horrible /o\ Arguably, a different more readable way to express the same query :
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?year (sample(?number) as ?number) (group_concat(?IATA;separator=" ") as ?IATAs)
WHERE {
?item wdt:P238 ?IATA ;
p:P3872 ?statement
VALUES ?IATA {"SIN" }
.
?statement pq:P585 ?time ;
ps:P3872 ?number
filter not exists {
?statement pq:P518 ?applies filter (?applies != wd:Q2165236) . # filtering out statements if they applies to a part that is not the whole (should not be necessary in a better model)
} .
MINUS { ?statement wikibase:rank wikibase:DeprecatedRank }
# computing statements who have « applies to part : everywhere »
optional {
?statement pq:P518 ?applies.
bind("everywhere" as ?everywhere)
}
bind (YEAR(?time) AS ?year).
# if everywhere is not bound, there is no applies
bind(coalesce(?everywhere, "no applies") as ?where)
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,ro,pt". }
} group by ?year ?item ?itemLabel
order by ?item desc (?year)