SQL: Select Nodes From JSON String

 select w.code, w.message, COUNT(*) from (SELECT io.iologEntryId, JSON_VALUE(payload, '$.envelope.error.code') as code, JSON_QUERY(payload, '$.envelope.error.message') as message 
 FROM [io-logging].[iologging].[iologEntries] io
 where resource like '%api-connect%'
 and payload like '%statusCode":"Error%'
 and ioType = 'HTTP_REQUEST' 
 ) w group by w.code, w.message order by w.code