title: How to apply aggregate functions(like MIN, MAX, COUNT) in JCR-SQL2?
body: <p>I have some records stored as Nodes in JCR and the name of the node is the primary key. eg 1,2,3.
  But the problem starts here,</p>
  
  <p>the records are as follows <strong>1,2,6,53,54</strong></p>
  
  <p>Where the numbers above are nodes under EMP unstructured node.
  If I do</p>
  
  <p><code>int count=empNode.getNodeIterator().getSize()</code> <strong>I will get 5</strong> As there are 5 nodes</p>
  
  <p>So I do count++ which gives me 6 but 6 already exists, <strong>so I can't create a node with name 6 under EMP[nt:unstructred], thats why I want to apply MAX(nodeNames)</strong> something in the query. What should I do ?</p>
  
  <p><strong>Update ::</strong>
  I use CQ5.5. EMP is an unstructered node under content like /content/EMP.
  Under this(EMP) I have unstructered nodes that hold my data. And these node have names as 1,2, etc</p>