I'm learning XQuery for the first time and I'm running into a spot of trouble with a particular query.
Find the names of the Makers who produce at least two PC's with speed of at least 2.00.
I've gotten the Speed<=2.00 part of the query down pat, but I can't quite figure out how to group this by number of occurrences.
Attempt: (outputs nothing)
let $doc := doc("PC.xml")
for $x in $doc/Products/Maker/PC
where $x/Speed>=2.00 and count($x)>=2
return $x/../@name
PC.xml:
<Products>
<Maker name = "A">
<PC model = "1001" price = "2114">
<Speed>2.66</Speed>
<RAM>1024</RAM>
<HardDisk>250</HardDisk>
</PC>
<PC model = "1002" price = "995">
<Speed>2.10</Speed>
<RAM>512</RAM>
<HardDisk>250</HardDisk>
</PC>
<Laptop model = "2004" price = "1150">
<Speed>2.00</Speed>
<RAM>512</RAM>
<HardDisk>60</HardDisk>
<Screen>13.3</Screen>
</Laptop>
<Laptop model = "2005" price = "2500">
<Speed>2.16</Speed>
<RAM>1024</RAM>
<HardDisk>120</HardDisk>
<Screen>17.0</Screen>
</Laptop>
</Maker>
<Maker name = "E">
<PC model = "1011" price = "959">
<Speed>1.86</Speed>
<RAM>2048</RAM>
<HardDisk>160</HardDisk>
</PC>
<PC model = "1012" price = "649">
<Speed>2.80</Speed>
<RAM>1024</RAM>
<HardDisk>160</HardDisk>
</PC>
<Laptop model = "2001" price = "3673">
<Speed>2.00</Speed>
<RAM>2048</RAM>
<HardDisk>240</HardDisk>
<Screen>20.1</Screen>
</Laptop>
<Printer model = "3002" price = "239">
<Color>false</Color>
<Type>laser</Type>
</Printer>
</Maker>
<Maker name = "H">
<Printer model = "3006" price = "100">
<Color>true</Color>
<Type>ink--jet</Type>
</Printer>
<Printer model = "3007" price = "200">
<Color>true</Color>
<Type>laser</Type>
</Printer>
</Maker>
</Products>