Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert character type into number type in SQL statement?
How to convert character type into number type in SQL statement?
First, check whether the data in the amount column meets the decimal specification, and use cast (amount as? decimal( 10,4))& gt; 500 or

Convert (decimal (10,4), amount) > 500.

Note: The length and number of decimal places are set according to your own needs.

Convert string numbers into numbers in sql:

Method 1: choose CAST(' 123' as the signature? Integer);

Method 2: select convert (' 123', signed);

Method 3: Select'123'+0;

Extended data:

If you can convert a character type to a number type, you can convert a number to a character. For the data type of exact value, the converted string is the value we store. For example:

Declare @i int

set @i= 123456789

print ' test:'+convert(varchar(20),@i)

The output is: test: 123456789.

However, it is not so simple for approximate numeric data types.

Declare @i float

set @i= 123456789

print ' test:'+convert(varchar(20),@i)

Output result: test: 1.23457e+008.