query-be7200b466d890fcc64c0bcc8e79d0ea

rq turtle/ttl

Tool: wbi_fastrun _query_data SELECT ?sid ?item ?v ?unit ?pq ?qval ?qunit WHERE { { SELECT ?item ?sid ?v WHERE { ?item http://www.wikidata.org/prop/direct/P699 ?zzP699 .

    # Get statement ID and the simple value for the statements
    ?item <http://www.wikidata.org/prop/P31> ?sid .
    ?sid <http://www.wikidata.org/prop/statement/P31> ?v .
}
ORDER BY ?sid OFFSET 0 LIMIT 10000

}

# Get the optional unit for statements with a quantity value OPTIONAL { ?sid http://www.wikidata.org/prop/statement/value/P31 / wikibase:quantityUnit ?unit . }

# Get qualifiers OPTIONAL { { # Get simple values for qualifiers which are not of type quantity ?sid ?propQualifier ?qval . ?pq wikibase:qualifier ?propQualifier . ?pq wikibase:propertyType ?qualifer_property_type . FILTER (?qualifer_property_type != wikibase:Quantity) } UNION { # Get amount and unit for qualifiers of type quantity ?sid ?pqv [wikibase:quantityAmount ?qval; wikibase:quantityUnit ?qunit] . ?pq wikibase:qualifierValue ?pqv . } } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
#Tool: wbi_fastrun _query_data
SELECT ?sid ?item ?v ?unit ?pq ?qval ?qunit
WHERE
{
  {
    SELECT ?item ?sid ?v
    WHERE
    {
        ?item <http://www.wikidata.org/prop/direct/P699> ?zzP699 .

        # Get statement ID and the simple value for the statements
        ?item <http://www.wikidata.org/prop/P31> ?sid .
        ?sid <http://www.wikidata.org/prop/statement/P31> ?v .
    }
    ORDER BY ?sid OFFSET 0 LIMIT 10000
  }

  # Get the optional unit for statements with a quantity value
  OPTIONAL
  {
    ?sid <http://www.wikidata.org/prop/statement/value/P31> / wikibase:quantityUnit ?unit .
  }

  # Get qualifiers
  OPTIONAL
  {
    {
      # Get simple values for qualifiers which are not of type quantity
      ?sid ?propQualifier ?qval .
      ?pq wikibase:qualifier ?propQualifier .
      ?pq wikibase:propertyType ?qualifer_property_type .
      FILTER (?qualifer_property_type != wikibase:Quantity)
    }
    UNION
    {
      # Get amount and unit for qualifiers of type quantity
      ?sid ?pqv [wikibase:quantityAmount ?qval; wikibase:quantityUnit ?qunit] .
      ?pq wikibase:qualifierValue ?pqv .
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v9("?pq"):::projected v11("?pqv") v7("?propQualifier") v6("?qualifer_property_type") v10("?qunit"):::projected v8("?qval"):::projected v1("?sid"):::projected v5("?unit"):::projected v4("?v"):::projected v3("?zzP699") a1((" ")) a2((" ")) v2 --http://www.wikidata.org/prop/direct/P699--> v3 v2 --http://www.wikidata.org/prop/P31--> v1 v1 --http://www.wikidata.org/prop/statement/P31--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -.http://www.wikidata.org/prop/statement/value/P31.-> a1 a1 --"wikibase:quantityUnit"--> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a2 -."wikibase:quantityAmount".-> v8 a2 --"wikibase:quantityUnit"--> v10 v1 -->v11--> a2 v9 --"wikibase:qualifierValue"--> v11 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f0[["?qualifer_property_type != 'wikibase:Quantity'"]] f0 --> v6 v1 -->v7--> v8 v9 --"wikibase:qualifier"--> v7 v9 --"wikibase:propertyType"--> v6 end union0r <== or ==> union0l end end