How to get the numbers from query in presto?

by cortez.connelly , in category: MySQL , 7 days ago

How to get the numbers from query in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , 6 days ago

@cortez.connelly 

To extract numbers from a query in Presto, you can use regular expressions. Here is an example query that shows how to get numbers from a given string:

1
SELECT regexp_extract_all('abc 123 xyz 456', '\d+') AS numbers;


In this query, the regexp_extract_all function is used to extract all the numbers (\d+) from the given string 'abc 123 xyz 456'. This will return an array of numbers [123, 456].


You can modify the regular expression pattern based on your specific requirements to extract numbers from a different format or pattern in the string.