我无法获得 XQuery 来计算两年内的销售额,它基于 SQL 查询。
SELECT [ShipCountry] & " " & [ShipCity] AS CountryAndCity, COUNT(OrderID) AS BiYearlySales
FROM Orders
WHERE (((OrderDate) BETWEEN #1/1/1996# And #1/1/1998#))
GROUP BY [ShipCountry] & " " & [ShipCity];
这是迄今为止我得到的 xquery,但它只计算每个实例一次。想不通为什么。我正在使用 Altova xmlspy - xquery 1.0。
<Result>
{
for $a in doc("Orders.xml")/dataroot/Orders
let $b := concat($a/ShipCountry, " ", $a/ShipCity)
where $a/OrderDate >= '1996-01-01T00:00:00' and $a/OrderDate <= '1998-01-01T00:00:00'
return
<BiYearlySales>
<CountryNameAndCity>{$b}</CountryNameAndCity>
<OrderCount>{count($a)}</OrderCount>
</BiYearlySales>
}
</Result>
我意识到我还没有完成这个小组,但尝试让这个工作更重要。