1

If I am given a list in XQuery, like: 1, 1, 2

How do I count the number of instances of 1s?

4

1 回答 1

3

The list is actually a sequence and you can count() it...

let $sequence := ('1','1','2')
return
    count($sequence[.='1'])

produces:

2

于 2013-03-30T23:54:21.990 回答