SELECT
CASE
WHEN MAX(column_name) = 'ZZ' THEN 'ZZ'
WHEN REGEXP_LIKE(MAX(column_name), '^[0-9]{2}$') THEN
CASE
WHEN MAX(column_name) = '99' THEN 'A1'
ELSE
CHR(ASCII(SUBSTR(MAX(column_name), 1, 1)) + 1) || '1'
END
WHEN REGEXP_LIKE(MAX(column_name), '^[A-Z][1-9]$') THEN
CASE
WHEN SUBSTR(MAX(column_name), 2, 1) = '9' THEN
SUBSTR(MAX(column_name), 1, 1) || 'A'
ELSE
SUBSTR(MAX(column_name), 1, 1) || CHR(ASCII(SUBSTR(MAX(column_name), 2, 1)) + 1)
END
WHEN MAX(column_name) = 'AZ' THEN 'B1'
END AS next_value
FROM table_name;
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme