title: MySQL - How to find number of occurance in JSON?
body: <p>I have following table -</p>
  <pre><code>+-----+-----------+--------------------------------------+
  | id  | client_id | service_values                       |
  +-----+-----------+------------+-------------------------+
  | 100 |      1000 | {&quot;1&quot;: &quot;60&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
  | 101 |      1000 | {&quot;1&quot;: &quot;66&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
  | 102 |      1000 | {&quot;1&quot;: &quot;70&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
  | 103 |      1001 | {&quot;1&quot;: &quot;60&quot;, &quot;2&quot;: &quot;54&quot;, &quot;3&quot;: &quot;92&quot;}    |
  | 104 |      1001 | {&quot;1&quot;: &quot;90&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
  | 105 |      1002 | {&quot;1&quot;: &quot;80&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
  +-----+-----------+--------------------------------------+
  </code></pre>
  <p>I need to fetch <strong>service_values</strong> where 2 or more values is LESS THAN 65. For example from the above records, the expected result would be -</p>
  <pre><code>    +-----+-----------+--------------------------------------+
      | id  | client_id | service_values                       |
      +-----+-----------+------------+-------------------------+
      | 100 |      1000 | {&quot;1&quot;: &quot;60&quot;, &quot;2&quot;: &quot;64&quot;, &quot;3&quot;: &quot;92&quot;}    |
      | 103 |      1001 | {&quot;1&quot;: &quot;60&quot;, &quot;2&quot;: &quot;54&quot;, &quot;3&quot;: &quot;92&quot;}    |
      +-----+-----------+--------------------------------------+
  </code></pre>
  <p>I find a lot but couldn't find anything to perform aggregate function in JSON data.</p>
  <p><strong>Update</strong> - I tried something like this but couldn't succeed -</p>
  <pre><code>SELECT JSON_UNQUOTE(JSON_EXTRACT(service_values,'$.1')) AS A1, JSON_UNQUOTE(JSON_EXTRACT(service_values,'$.2')) AS A2, JSON_UNQUOTE(JSON_EXTRACT(service_values,'$.3')) AS A3 FROM service_data HAVING A1 &lt; 65 OR A2 &lt; 65 OR A3 &lt; 65
  </code></pre>