query-d7f91718dd6a1dd2526a33aca3bf62e4

rq turtle/ttl

It would be nice having a simple way to get truthy statements in WDQS It is often the case that you need more information about a statement than a simple value. That can be e.g. qualifiers, references, value precision, value unit or others things. In these cases you have to use the p: prefix instead of wdt: but you often still want to access only truthy statements. It is possible to add a test for truthyness, like this:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
?item p:P1532 ?statement.
    ?statement ps:P1532 ?represents.
    ?statement pq:P582 ?end_time.

    # Select only truthy statements
    ?statement wikibase:rank ?rank.
    FILTER (?rank = wikibase:PreferredRank ||
            ?rank = wikibase:NormalRank && NOT EXISTS { ?item p:P1532/wikibase:rank wikibase:PreferredRank. })

Query found at