如何返回字符串序列?
答案 0 :(得分:2)
自2014年以来的XQuery支持您可以使用的group by
子句:
for $dept at $pos in //building[year = '1900']/department
group by $key := $dept
order by $pos[1]
return ($key || ' ' || count($dept))
https://xqueryfiddle.liberty-development.net/gWcDMen
如果没有XQuery 3支持,则可以使用
let $dept := //building[year = '1900']/department
for $dist-dept in distinct-values($dept)
return
concat($dist-dept, ' ', count($dept[. = $dist-dept]))