Home > Back-end >  Data retention decimal
Data retention decimal

Time:10-21

Such as: the decimal 4.1 4.2 4.3 4.4 all save for 4
All save 4.5 4.6 4.7 4.8 4.9 to 4.5 how SQL2000 database


Great god action such as online, thank you

CodePudding user response:

The best before logging data disposal. The second USES a trigger to handle

CodePudding user response:

The function TForm1. The HandleData (AData: Double) : Double;
Var
ITemp: Integer;
The begin
ITemp=Trunc (AData);
If (AData - iTemp) & gt;=0.5 then the Result:=iTemp + 0.5
The else Result:=iTemp;
end;

Write a function after processing can be saved to the database!

CodePudding user response:


- database processing functionThe Create FUNCTION HandleData (@ AData numeric (10, 2))
Returns numeric (10, 2)
As
The begin

Declare @ iTemp int, @ nTemp numeric (10, 2)

The set @ iTemp=FLOOR (@ AData)

If (@ AData - @ iTemp) & lt; 0.5
The set @ nTemp=@ iTemp
The else
The set @ nTemp=@ iTemp + 0.5

Return the @ nTemp
End

- test statements
The select dbo. The HandleData (4.9888888)

CodePudding user response:

Select a case when 4.7 FLOOR (4.7) & lt; 0.5 then FLOOR (4.7) else FLOOR (4.7) + 0.5 end Test

You put 4.7 to change your field name

CodePudding user response:

Don't checkout don't programmers
  • Related