问题描述
我需要在下面显示不带标签的xquery的数据,因此,如果您能帮助我,我将不胜感激。您怎么知道我已经有了查询。
(: Output the customer names of each pair of customers who are associated with the same
rep. There should not be any duplicate reversed pair and no customer be paired with the
same customer.:)
<result>
{
for $customer1 in doc ("../premiere/Customer.xml")//Customer,$customer2 in doc ("../premiere/Customer.xml")//Customer
where $customer1/RepNum = $customer2/RepNum and $customer1/CustomerNum < $customer2/CustomerNum
order by $customer1/CustomerName
return
<pair>
"{$customer1/CustomerName}"
"{$customer2/CustomerName}"
</pair>
}
</result>
<result>
<pair>
"<CustomerName>Al's Appliance and Sport</CustomerName>"
"<CustomerName>Kline's</CustomerName>"
</pair>
<pair>
"<CustomerName>Al's Appliance and Sport</CustomerName>"
"<CustomerName>All Season</CustomerName>"
</pair>
.
.
.
<pair>
"<CustomerName>The Everything Shop</CustomerName>"
"<CustomerName>Deerfield's Four Seasons</CustomerName>"
</pair>
</result>
我的输出必须是:
<results>
<pair>Al's Appliance and Sport - Kline's</pair>
<pair>Al's Appliance and Sport - All Season</pair>
<pair>Bargains galore - Johnson's Department Store</pair>
<pair>brookings Direct - The Everything Shop</pair>
<pair>brookings Direct - Lee's Sport and Appliance</pair>
<pair>brookings Direct - Deerfield's Four Seasons</pair>
<pair>Ferguson's - Bargains galore</pair>
<pair>Ferguson's - Johnson's Department Store</pair>
<pair>Kline's - All Season</pair>
<pair>Lee's Sport and Appliance - Deerfield's Four Seasons</pair>
<pair>The Everything Shop - Lee's Sport and Appliance</pair>
<pair>The Everything Shop - Deerfield's Four Seasons</pair>
</results>
解决方法
代替
<pair>
"{$customer1/CustomerName}"
"{$customer2/CustomerName}"
</pair>
请尝试以下操作:
<pair>{concat(data($customer1/CustomerName),' - ',data($customer2/CustomerName))}</pair>