Open this example in the interactive library
Source code
WITH items AS (SELECT value,min(key) AS first_seen FROM json_each('["b","a","b","c"]') GROUP BY value) SELECT json_group_array(value ORDER BY first_seen) AS items FROM items;
Sample output
[
{
"items": "[\"b\",\"a\",\"c\"]"
}
]