からの選択順序を制御するにはどうすればよいfor $x in (...)
ですか? $retmax
以下の XQuery の最後の行では、結果を , の順序にしたいのですが$retmin
、逆の順序で出力されます。
<result>
{
let $max := max(doc("countries.xml")//country/(@population div @area))
let $min := min(doc("countries.xml")//country/(@population div @area))
for $country in doc("countries.xml")//country
let $density := $country/(@population div @area)
let $ret_min := if ($density = $min)
then <lowest density="{$density}">{data($country/@name)}</lowest>
else ()
let $ret_max := if ($density = $max)
then <highest density="{$density}">{data($country/@name)}</highest>
else ()
for $r in ($ret_max, $ret_min) return $r
}
</result>
生成:
<result>
<lowest density="0.026752619966905682">Greenland</lowest>
<highest density="31052.3125">Macau</highest>
</result>
でも私はしたい:
<result>
<highest density="31052.3125">Macau</highest>
<lowest density="0.026752619966905682">Greenland</lowest>
</result>