Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
WITH input AS ( SELECT '302(01:03)' AS input_string ), parsed AS ( SELECT SUBSTRING(input_string FROM '^[0-9]{3}') AS prefix, CAST(SUBSTRING(input_string FROM '\((\d+):') AS INTEGER) AS range_start, CAST(SUBSTRING(input_string FROM ':\d+\)') AS INTEGER) AS range_end FROM input ) SELECT prefix || LPAD(generate_series(range_start, range_end)::TEXT, 2, '0') AS account_number FROM parsed

Stuck with a problem? Got Error? Ask AI support!

Copy Clear