[SOLVED] separate number digits postgresql

Issue

i’m trying to find an sql function that can split a number into separate digits.
ex. num=78912346
split_num(num)={7,8,9,1,2,3,4,6}

Solution

You can use string_to_array with a null delimiter

select string_to_array(78912346::text, null)

Answered By – a_horse_with_no_name

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *