在下面的xml:如何在添加XQuery中少數節點的值後獲取不同的值?
<mo>
<customers>
<customer cno="2222">
<cname>Charles</cname>
<street>123 Main St.</street>
<city>Wichita</city>
<zip>67226</zip>
<phone>316-636-5555</phone>
</customer>
<customer cno="1000">
<cname>Bismita</cname>
<street>Ashford Dunwoody</street>
<city>Wichita</city>
<zip>67226-1555</zip>
<phone>000-000-0000</phone>
</customer>
</customers>
<employees>
<employee eno="1000">
<ename>Jones</ename>
<city>Wichita</city>
<zip>67226-1555</zip>
<hdate>1995-12-12</hdate>
</employee>
<employee eno="2000">
<ename>Asmit</ename>
<city>Wichita</city>
<zip>67226-1555</zip>
<hdate>1967-08-13</hdate>
</employee>
<employee eno="1003">
<ename>Axaya</ename>
<city>BBSR</city>
<zip>67226</zip>
<hdate>1978-08-13</hdate>
</employee>
</employees>
<parts>
<part pno="10506">
<pname>Land Before Time I</pname>
<qoh>200</qoh>
<price>319.99</price>
<level>20</level>
</part>
<part pno="10000">
<pname>Bottle</pname>
<qoh>2</qoh>
<price>3.00</price>
<level>2</level>
</part>
<part pno="10508">
<pname>Land Before Time 3</pname>
<qoh>202</qoh>
<price>2.00</price>
<level>22</level>
</part>
<part pno="10509">
<pname>Cycle</pname>
<qoh>202</qoh>
<price>1.00</price>
<level>22</level>
</part>
</parts>
<orders>
<order ono="1000" takenBy="1000" customer="2222" >
<receivedDate>1967-08-17</receivedDate>
<shippedDate>1967-08-13</shippedDate>
<items>
<item>
<partNumber>10508</partNumber>
<quantity>2</quantity>
</item>
</items>
</order>
<order ono="1001" takenBy="1000" customer="1000" >
<receivedDate>1968-08-14</receivedDate>
<shippedDate>1968-08-11</shippedDate>
<items>
<item>
<partNumber>10000</partNumber>
<quantity>2</quantity>
</item>
</items>
</order>
<order ono="1022" takenBy="1003" customer="2222" >
<receivedDate>1995-02-14</receivedDate>
<shippedDate>1995-02-13</shippedDate>
<items>
<item>
<partNumber>10000</partNumber>
<quantity>1</quantity>
</item>
<item>
<partNumber>10508</partNumber>
<quantity>2</quantity>
</item>
<item>
<partNumber>10509</partNumber>
<quantity>3</quantity>
</item>
</items>
</order>
</orders>
</mo>
如何獲得訂單號和他們的總價格爲每個訂單? 我試過下面的XQuery:
for
$o in /mo/orders/order,
$p in /mo/parts/part
where
$o/items/item/partNumber = data($p/@pno)
return concat(data($o/@ono),'-', sum($p/price))
它返回的訂單號與seprated總價「 - 」符號,但是,返回由於訂單中的多個項目重複。 當前結果:
1000-2 1001-3 1022-3 1022-2 1022-1
預期的結果:
1000-2 1001-3 1022-6
任何幫助來獲得的訂單數量的不同值與總價格???
爲什麼你在這裏添加C#標籤?我沒有看到與C#相關的任何內容。 – 2013-04-21 15:59:21
您忘了再次購買已購物品的數量。 – 2013-04-21 16:11:08