Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewiz/6d6e3972c44e3b85ef5b to your computer and use it in GitHub Desktop.
Save joewiz/6d6e3972c44e3b85ef5b to your computer and use it in GitHub Desktop.
Travels of the Secretary of State, sorted by trip duration (longest to shortest), using XQuery
xquery version "3.0";
for $trip in collection('/db/cms/apps/travels/data/secretaries')/trips/trip
let $duration := xs:date($trip/end-date) - xs:date($trip/start-date)
order by $duration descending
return <trip duration="{$duration}">{ $trip }</trip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment