title: XQuery get distinct values
body: <p>Im new to XQuery and are trying to learn how to use it with BaseX.</p>
  <p>I have this xml containing multiple elements of <strong>program</strong>:</p>
  <pre><code>&lt;program id=&quot;4565&quot;&gt;
          &lt;name&gt;Musiken i P3&lt;/name&gt;
          &lt;url&gt;http://sverigesradio.se/sida/default.aspx?programid=4565&lt;/url&gt;
          &lt;editor&gt;Anna-Karin Larsson&lt;/editor&gt;
          &lt;channel&gt;164&lt;/channel&gt;
          &lt;category&gt;5&lt;/category&gt;
  &lt;/program&gt;
  </code></pre>
  <p>So far i have understod that i can get the distinct values of for example editor like such:</p>
  <pre><code>let $vals := $sr/sr/programs/program/editor
  let $uniqe-items := distinct-values($vals)
  
  for $vals in $uniqe-items
      order by $vals
      return &lt;li&gt;{string($vals)}&lt;/li&gt;
  </code></pre>
  <p>However when i do this I only get the editors name and I can't understand how i also check something like this:</p>
  <pre><code> let $vals := $sr/sr/programs/program/editor
   let $uniqe-items := distinct-values($vals)
  
   for $vals in $uniqe-items
       where $vals/channel = &quot;132&quot;
       order by $vals
       return &lt;li&gt;{string($vals)}&lt;/li&gt;
  </code></pre>
  <p>I was thinking that i could do something like <code>$vals/../channel</code> to get back to the channel attribute but that doesn't seem to be the case.</p>