title: XMLQuery in Oracle
body: <p>I want to filter some elements from the following database:</p>
  
  <pre><code>`CREATE TABLE Club
  ( name         VARCHAR2(30),
    championship XMLTYPE);`
  </code></pre>
  
  <p>The XML-part looks like this:</p>
  
  <pre><code>`INSERT INTO Club VALUES ('FC Arsenal',
  '&lt;championship&gt;
      &lt;champion no="13"&gt;
          &lt;league&gt;PremierLeague&lt;/league&gt;
          &lt;year&gt;2004&lt;/&lt;year&gt;
      &lt;/champion&gt;
      &lt;champion no="11"&gt;
          &lt;league&gt;FA_Cup&lt;/league&gt;
          &lt;year&gt;2014&lt;/year&gt;
      &lt;/champion&gt;
  &lt;/championship&gt;'
  );`
  </code></pre>
  
  <p>I want to filter the name of the club and the year but only if the team won the premier league.</p>
  
  <p>My solution looks like this:</p>
  
  <pre><code>`SELECT Name, XMLQuery(
    'for $i in /championship
      where $i/champion/league = "PremierLeague"
      return $i/champion/year
      PASSING Club RETURNING content) As year
  FROM Club;`
  </code></pre>
  
  <p>I'm not sure how I can combine the query, so that the name depends on the xmlquery. Now I get all names of the clubs even if the don't won the Premier League. Another problem is that I get the name but the year is (null).</p>
  
  <p>What is wrong?</p>
  
  <p>Thank's</p>