The JSON path accessor [last]
picks the last element of a JSON array.
SELECT JSON_VALUE('["A", "B", "C"]', '$[last]')
FROM …
The JSON path expression [last]
in this example returns the value "C"
as it is the last element in the JSON array.
Primer: “JSON Path”
Other SQL/JSON path array accessors:
Multiple subscripts: [<e>, <e>, …]
Ranges: [… to …]
The SQL/JSON path language first appeared in ISO/IEC 9075:2016-2 as part of optional feature T821, “Basic SQL/JSON query operators”.
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »