Good afternoon!
I have a collection of XML files in which all files contain the attribute //ENDERECO-PROFISISONAL/@UF
In which UF is the province in which the person to whom the file makes reference to lives.
I want to develop a query that returns to me the number of occurences of each province in the collection. I've tried using count and distinct-values, but it always return the value "1" for me.
The query I'm trying to use is the following: for $x in collection('Teste500')/CURRICULO-VITAE/DADOS-GERAIS/ENDERECO/ENDERECO-PROFISSIONAL let $y := count(distinct-values($x/@UF)) return $y
The desired result would be, in a collection of documents in which 5 people live in SP, 3 in DF and 9 in AM would be the following:
SP: 5 DF: 3 AM:9
Can somebody please help me with that? I'm still struggling with xQuery.
Hi Ana,
The "group by" clause will help you here [1]. Hope this helps; feel free to ask if you need more examples.
Christian
[1] http://docs.basex.org/wiki/XQuery_3.0#group_by
On Fri, Nov 20, 2015 at 6:06 PM, Ana Victória Ladeira ladeira.ana@gmail.com wrote:
Good afternoon!
I have a collection of XML files in which all files contain the attribute //ENDERECO-PROFISISONAL/@UF
In which UF is the province in which the person to whom the file makes reference to lives.
I want to develop a query that returns to me the number of occurences of each province in the collection. I've tried using count and distinct-values, but it always return the value "1" for me.
The query I'm trying to use is the following: for $x in collection('Teste500')/CURRICULO-VITAE/DADOS-GERAIS/ENDERECO/ENDERECO-PROFISSIONAL let $y := count(distinct-values($x/@UF)) return $y
The desired result would be, in a collection of documents in which 5 people live in SP, 3 in DF and 9 in AM would be the following:
SP: 5 DF: 3 AM:9
Can somebody please help me with that? I'm still struggling with xQuery.
basex-talk@mailman.uni-konstanz.de