title: How return total distinct user in last 30 days dateCreated
body: <p>There are lots of audit documents in my database like below</p>
  
  <pre><code>&lt;Record&gt;
    &lt;objectType&gt;Audit&lt;/objectType&gt;
    &lt;dateCreated&gt;2017-04-07T03:51:56.231-04:00&lt;/dateCreated&gt;
    &lt;createdBy&gt;first user&lt;/createdBy&gt;
  &lt;/Record&gt;
  </code></pre>
  
  <p>How can I get total number of user(createdBy) who created audit file in last 30 days? There are some audit files in which createdBy same so we require distinct value count.</p>
  
  <p>I tried the query below:</p>
  
  <pre><code>let $query := cts:values(cts:element-reference(fn:QName($NS, "createdBy")))
  return fn:count($query)
  </code></pre>
  
  <p>But how can I use condition <code>dateCreated&gt;30</code> or <code>cts:range-query</code> inside <code>cts:values</code>.
  Is there any other way to achieve this? </p>
  
  <p>(I have set up element range index for createdBy and dateCreated)</p>