*/ explanation: 
an sql that runs on OBJECTS table by object ID and JSON_Version and returns the most updated object, that his JSON_Version value is equal or if no equal is one above the give JSON_Version
for example if  we have this data in records
ID = 100, date = 01/10/24,  version = 1.9
ID = 100, date = 05/10/24,  version = 1.9
ID = 100, date = 01/10/24,  version = 1.8
ID = 100, date = 01/11/24,  version = 1.8
ID = 100, date = 09/10/24,  version = 1.79
ID = 100, date = 09/11/24,  version = 2.1

if we look for object id=100 in version 1.8 and
we will get the record with ID = 100, date = 01/11/24,  version = 1.8

if we look for object id=100 in version 1.81 and
we will get the record with ID = 100, date = 05/10/24,  version = 1.9

if we look for object id=100 in version 1.5 and
we will get the record with ID = 100, date = 09/10/24,  version = 1.79
*/

// Select by Object ID
  
SELECT *
FROM OBJECTS
WHERE ID = 100
  AND JSON_EXTRACT(JSON, '$.JSON_Version') = (
    SELECT JSON_EXTRACT(JSON, '$.JSON_Version')
    FROM OBJECTS
    WHERE ID = 100
      AND (
        JSON_EXTRACT(JSON, '$.JSON_Version') = '1.8' OR
        JSON_EXTRACT(JSON, '$.JSON_Version') > '1.8'
      )
    ORDER BY JSON_EXTRACT(JSON, '$.JSON_Version') ASC
    LIMIT 1
  )
ORDER BY UpdateTime DESC
LIMIT 1;

// Select by Object name
SELECT *
FROM OBJECTS
WHERE JSON_EXTRACT(JSON, '$.ObjectName') = 'Page'
  AND JSON_EXTRACT(JSON, '$.JSON_Version') = (
    SELECT JSON_EXTRACT(JSON, '$.JSON_Version')
    FROM OBJECTS
    WHERE JSON_EXTRACT(JSON, '$.ObjectName') = 'Page'
      AND (
        JSON_EXTRACT(JSON, '$.JSON_Version') = '1.8' OR
        JSON_EXTRACT(JSON, '$.JSON_Version') > '1.8'
      )
    ORDER BY JSON_EXTRACT(JSON, '$.JSON_Version') ASC
    LIMIT 1
  )
ORDER BY UpdateTime DESC
LIMIT 1;
