title: Azure Cosmos DB SQL API stored procedure example
body: <p>I am new to Azure Cosmos DB and I'm trying to create a stored procedure using SQLAPI to return data.</p>
  <p>Using the following as an example:</p>
  <pre><code>{ 
    &quot;id&quot;:&quot;123&quot;,
    &quot;fname&quot; : &quot;John&quot;,
    &quot;lname&quot; : &quot;Doe&quot;,
    &quot;receivedTime&quot; : &quot;08/08/2019 09:54:57&quot;,
    &quot;subjects&quot; : [
  {
     &quot;subjectid&quot; : &quot;01&quot;,
     &quot;subjectname&quot; : &quot;English&quot;
     &quot;subjectmark&quot; : &quot;80&quot;
  },
  {
     &quot;subjectid&quot; : &quot;02&quot;,
     &quot;subjectname&quot; : &quot;Math&quot;
     &quot;subjectmark&quot; : &quot;70&quot;
  }
  ]
  }
  </code></pre>
  <p>How would I build a stored procedure to return the root data as well as the average of the subjectmarks?</p>