S Ringne S Ringne - 1 month ago 20
SQL Question

Select from column where value starts with 1

i have a table T

id val1
a 199.87
b 166.56
c 100.67
d 233.45
e 177.23



  1. I want to select those rows where
    val1
    starts with 1

  2. rows where
    val1
    starts with 19.



Is there any way of doing this in SQL Server.

The data type of val1 is float.

Answer Source

1) I want to select those rows where val1 starts with 1

SELECT
  *
FROM Table_1
WHERE val1 LIKE '1%'

output1

2) rows where val1 starts with 19.

SELECT
  *
FROM Table_1
WHERE val1 LIKE '19%'

output2