order by stateCt : order by « XQuery « XML






order by stateCt


File: Data.xml


<order>
  <car dept="A">
    <number>1</number>
    <name language="en">name 1</name>
  </car>
  <car dept="B">
    <number>2</number>
    <name language="en">name 2</name>
  </car>
  <car dept="B">
    <number>3</number>
    <name language="en">name 3</name>
  </car>
  <car dept="C">
    <number>4</number>
    <name language="en">name 4</name>
  </car>
</order>


File: Query.xquery


for $prod in doc("Data.xml")//car
where $prod/@dept = "B"
order by $prod/name
return $prod/name


Output:

<?xml version="1.0" encoding="UTF-8"?>
<name language="en">name 2</name>
<name language="en">name 3</name>

 








Related examples in the same category

1.order by clause demo
2.The order by clause
3.Using multiple inventorying specifications
4.Inadvertent resorting in document inventory
5.without inadvertent resorting
6.Using an inventory comparison