substring function

The substring function extracts a string from a given string according to a given numeric starting position and a given numeric substring length.

returnvalue substring (source, position [, substring_length] )

source ::= any*
position ::= integer*
substring_length ::= integer*
returnvalue ::= string

Example 1 - Fetch the first three characters from the routing details of a passenger with ticket number **1762376407826.**

SELECT substring(bag.baginfo.routing,0,3) AS Source
FROM baggageInfo bag
WHERE ticketNo=1762376407826

Output:

{"Source":"JFK"}