SQL to convert numbers to currency format
Currency field types generally include int, float, money / smallmoney, decimal / numeric
select according to the accuracy of the stored data:
int can only store integer money
Themoney / smallmoney data types are accurate to one ten thousandth of the monetary unit they represent
decimal / numberic can customize the decimal places and the data precision that can be stored, so generally more people use this type
float is not suitable for currency which needs precise value
conclusion:
it is best to use money and decimal types in finance
if it is a simple calculation, the float type can be used, but the data fetched by the float type on some platforms is not so accurate, and the accuracy may be lost. Therefore, if the cost is not great in a stable performance platform, it is recommended to use the above two types
extended data:
SQL data type:
1, bit integer
bit data type is integer, its value can only be 0, 1 or null. This data type is used to store data with only two possible values, such as yes or no, true or false, on or off.
note: it is a data type that saves a lot of space. If it can meet the requirements, it should be used as much as possible
The 2, tinyint integer
tinyint data type can store integers from 0 to 255. It's useful when you're only going to store a limited number of values. This data type occupies 1 byte in the database
The 3, smallint integer
smallint data type can store integers from the 15th power (- 32768) of - 2 to the 15th power (32767) of 2. This kind of data type is very useful for storing some numerical data which is often limited in a specific range. This data type takes up two bytes of space in the database
The4, int integer
int data type can store integers from the 31st power of - 2 (- 2147483648) to the 31st power of 2 (2147483647). Almost all numerical data stored in the database can use this data type. This data type takes up four bytes in the database
The5, decimal precise numerical type
decimal data type can be used to store numerical data with fixed precision and range from - 10 to - 10. When using this data type, you must specify the range and precision. The range is the total number of digits that can be stored around the decimal point. Precision is the number of digits stored to the right of the decimal point
Numerical data type is similar to decimal7, smallmoney
smallmoney data type is used to represent money and monetary value. This data type can store data from - 214748.3648 to 214748.3647, accurate to one ten thousandth of the monetary unit
8, money type
money data type is used to express money and monetary value. This data type can store data from - 922 billion to 922 billion, accurate to one ten thousandth of the monetary unit
9, float approximate value type
float data type is an approximate value type for floating-point numbers. Floating point numbers are approximate because not all numbers in their range can be expressed accurately. Floating point numbers can be any number from - 1.79e + 308 to 1.79e + 308
10, real approximate value
real data type is similar to floating-point number, it is approximate value type. It can represent floating-point numbers with values between - 3.40e + 38 and 3.40e + 38
Director Sun Liqun and Secretary of the Party committee are responsible for the overall work of the center
deputy director Liu Bin is in charge of the office, personnel department, finance department, Liaoning venture capital guidance fund management center and network engineering department
deputy director Jiang Jianli is in charge of the macroeconomic early warning and forecasting center and Liaoning Provincial Information Center
deputy director Wang Jiaren is in charge of the information engineering evaluation department, information resources department, information resources department, etc Logistics office
for reference only