0

I have been given a station in london - warren street station, euston, and i have to return the stations which have the same bike availability as warren street station and at least as many empty docs. I have written a small query to return warren street station and its availability but how to I return a list of all other stations that have the same availability/ as many empty docks as my warren street station?

    <results>{  for $b in doc("http://tinyurl.com/TFLStationsXMLFile")
    /stations/station
    where $b/name = "Warren Street Station, Euston"
    order by $b
    return    
    <result>      
    { $b/name }          
    { $b/nb_bikes }
    { $b/nb_empty_docks }
    </result>}
    </results>
Emma
  • 1

1 Answers1

0
let $warren-station := doc("http://tinyurl.com/TFLStationsXMLFile")/stations/station[name eq "Warren Street Station, Euston"]
return
<results>{  for $b in doc("http://tinyurl.com/TFLStationsXMLFile")/stations/station    
    where $b/nb_bikes eq $warren-station/nb_bikes and  $b/nb_empty_docks ge $warren-station/nb_empty_docks
    order by $b
    return    
    <result>      
    { $b/name }          
    { $b/nb_bikes }
    { $b/nb_empty_docks }
    </result>}
</results>

Something like that. HTH!

John Smith
  • 1,559
  • 1
  • 12
  • 18