Most databases support left(), so you can do something like this:
select id,
(case when left(time, 1) between 'a' and 'z' or left(time, 1) between 'A' and 'Z'
then SSS else TIN
end) as Legal_Doc_no
from tbl1;
There may be other solutions depending on the database.
In SQL Server, you can:
select id,
(case when time like '[a-z]%'
then SSS else TIN
end) as Legal_Doc_no
from tbl1;
If you have a case sensitive account, then you need to consider this:
select id,
(case when lower(time) like '[a-z]%'
then SSS else TIN
end) as Legal_Doc_no
from tbl1;
source
share