Following is the XML file -
<Info>
<Name>
<P1>Tomy</P1>
<P2>John</P2>
<R>P2</R>
</Name>
<Name>
<P1>Tomy</P1>
<P2>John</P2>
<R>P1</R>
</Name>
<Name>
<P1>Rojer</P1>
<P2>Messi</P2>
<R>P2</R>
</Name>
<Name>
<P1>Messi</P1>
<P2>Carl</P2>
<R>P2</R>
</Name>
<Name>
<P1>Messi</P1>
<P2/>
<R>P1</R>
</Name>
</Info>
P1
is the Player No 1 and P2
is the Player No 2, R
is the result of the match.
I want to list the names of Players in following format, with distinct occurences.
<P>Tomy V John</P>
<P>Rojer V Messi</P>
<P>Messi V John</P>
<P>Messi</P>
Following is the solution, which gives the desired output -
let $o := doc('sam')//Name
for $x in $o
let $p := if (string-length($x/P2/text()) > 0) then concat($x/P1/text(),' Vs. ',$x/P2/text()) else $x/P1/text()
for $y in $p
group by $y
order by $y
return <a>{$y}</a>
But this query works better only for some selected records. In actual, I have 200000+ records, and when I execute this query, I get Out Of Memory Error. I am using BaseX 7.6.
If I remove the group by
clause, the executes without error, but it gives the wrong result ie; with duplicate values. I need distinct result.
Any help ?