Topic on Talk:Wikidata Query Service/Archive 2

Data from query not returned even though it appears on page

3
Stuchalk (talkcontribs)

The following query returns data for the first three tributaries of Lake Geneva but not others, even though there is data available.

SELECT ?trib ?tribLabel ?length ?elevation ?area ?discharge

WHERE

{

  wd:Q6403 wdt:P200 ?trib .

  OPTIONAL {

  ?trib wdt:P2043 ?length .

  ?trib wdt:P2053 ?area .

  ?trib wdt:P2044 ?elevation .

  ?trib wdt:P2225 ?discharge .

   }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }

} ORDER BY DESC(?length) ?tribLabel

LIMIT 50


For tributary 'Eau Floride' (and others) the data exists on the wikidata entry page but is not showing up via this query. Why not? See the images below...

Length - Eau Froide
Length of the river 'Eau Froide' on Wikidata.
Watershed area - Eau Froide
Watershed area information for the river 'Eau Froide'.
Fnielsen (talkcontribs)

You need individual OPTIONALs

SELECT
  ?trib ?tribLabel ?length ?elevation ?area ?discharge
WHERE {
  wd:Q6403 wdt:P200 ?trib .
  OPTIONAL { ?trib wdt:P2043 ?length }
  OPTIONAL { ?trib wdt:P2053 ?area }
  OPTIONAL { ?trib wdt:P2044 ?elevation }
  OPTIONAL { ?trib wdt:P2225 ?discharge }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY DESC(?length) ?tribLabel
LIMIT 50

Try it!

- Fnielsen (talk) 16:49, 14 June 2023 (UTC)

Stuchalk (talkcontribs)

Ah, thanks for the clarification on this. I keep forgetting that optional has to be individual items.

Reply to "Data from query not returned even though it appears on page"