Hi,

I have some data with the below format.

<student>
                <name>Mark</name>
                <grade>A</grade>
                <year>2016</year>
</student>

I need to find out in between 2011 to 2016, how many students got grade A, how 
many got grade B, how many got grade C.

I initially wrote a query like this.


xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;

for $grade in
cts:element-values(
      xs:QName('grade'),
      (),
      ("frequency-order"),
      cts:and-query((
        cts:element-range-query(xs:QName('year'), '>=', xs:int(2011)),
        cts:element-range-query(xs:QName('year'), '<=', xs:int(2016)),
        cts:element-range-query(xs:QName('grade'), '=', ('A', 'B', 'C'))
      ))
)
 return concat("grade :", $grade, " students with this grade :" , 
cts:frequency($grade))




I was expecting only grade A, B and C in the output but to my surprise, I am 
getting other grades as well like D, E, F and so on.

What am I missing here and is there any efficient way to achieve this? I have 
around 160 million records.


-Sudheer
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to