title: Change Datatype of json_value during select into so I can sum column
body: <p>I have a column in a table that is json.  It contains several columns within it.  </p>
  
  <p>Example:</p>
  
  <ul>
  <li>Row1:  <code>"sTCounts":[{"dpsTypeTest":"TESTTRIAL","cnt":3033244.0}</code></li>
  <li>Row2:  <code>"sTCounts":[{"dpsTypeTest":"TESTTRIAL","cnt":3.3}</code></li>
  </ul>
  
  <p>I need to sum the cnt value for all rows in table.  For instance, the above would produce a result of 3033247.3</p>
  
  <p>I'm not familiar with stored procs enough to master.  I thought the easiest route would be to create a temp table and extract the value into a column, and then write a query to sum the column values.</p>
  
  <p>The problem is that it creates a column with datatype <code>nvarchar(4000)</code>.  It won't let me sum that column.  I thought of changing the datatype but not sure how.  I am trying <code>CAST</code> without luck.</p>
  
  <pre><code> select CAST(json AS varchar) AS JSON_VALUE(jsontext, 
  '$.sTCounts.cnt') AS PerfCount, TitleNumber 
  INTO dbo_Testing_Count0
  from PerformanceTest
  
  select sum(PerfCount)
  from dbo_Testing_Count
  Group by PerfCount
  </code></pre>
  
  <p>The error message is:</p>
  
  <blockquote>
    <p>Incorrect syntax near 'jsontext'.</p>
  </blockquote>
  
  <p>Any ideas?  I am open to another method to sum the column or changing the datatype whichever the experts can aid on.  I appreciate it.</p>