Skip to main content
Solved

How to check if a number starts with 10? this number might consists of any number of digits '1023456789', the most important thing it starts with 10 and i don't care about the rest.

  • August 13, 2024
  • 2 replies
  • 5 views

Will

 

Case When var_number IN (10)

 

get the correct result?

 

Thank you.

Best answer by manuel.wetze

This is highly dependent on the datatype of your column.

I would use

CASE WHEN

LEFT(var_number,2)='10' THEN 'yes'

ELSE 'no'

 

 

but this assums that varnumber is a string already. If not you have to make it one using TO_STRING.

 

 

2 replies

manuel.wetze
Level 9
Forum|alt.badge.img+8
  • Level 9
  • Answer
  • August 13, 2024

This is highly dependent on the datatype of your column.

I would use

CASE WHEN

LEFT(var_number,2)='10' THEN 'yes'

ELSE 'no'

 

 

but this assums that varnumber is a string already. If not you have to make it one using TO_STRING.

 

 


  • Author
  • Level 5
  • August 13, 2024

This is highly dependent on the datatype of your column.

I would use

CASE WHEN

LEFT(var_number,2)='10' THEN 'yes'

ELSE 'no'

 

 

but this assums that varnumber is a string already. If not you have to make it one using TO_STRING.

 

 

Thank you for your reply!

 

The data type is CHAR. I think it might work with Char, otherwise I will convert it.