Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
eclipce051
Starting Member
5 Posts |
Posted - 2008-09-11 : 10:28:55
|
| Hi i am caind of new in the area so i will ask for all the help and understanting...Well the problem is as follows i have a table that has a money type value it stores a 4 decimals (ex.47.4848) when i do an operation ver the values like a sum it sums up all value with the 4 decimal; the problems is that i need to sum the values with just 2 decimals.tkx for all the help guys :sLife is short get a rest and go out with some chiks :P |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-11 : 10:32:15
|
round to 2 decimal then sum itsum(round(col, 2)) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-11 : 10:49:12
|
round(sum(col), 2) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-11 : 11:03:06
|
[code]DECLARE @Sample TABLE ( i SMALLMONEY )INSERT @SampleSELECT 0.0051 UNION ALLSELECT 0.0052 UNION ALLSELECT 0.0053 UNION ALLSELECT 0.0054 UNION ALLSELECT 0.0055SELECT SUM(ROUND(i, 2)) AS khtan, ROUND(SUM(i), 2) AS PesoFROM @Sample[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
eclipce051
Starting Member
5 Posts |
Posted - 2008-09-25 : 12:34:48
|
| ok i find a way to do the round as a truncated round (40.4848),2,1 the result is 40.4800; the stuff is that when i do this on an operation like this one:select round(SUM(CASE WHEN dfa.apitbis = 1 THEN (dfa.monto * (fa.pctitbis * 0.01)) ELSE 0 END)),2,1 as ITBIS from tfacturasthe result works some times some others gose like 60.000999999999..the bases of the operation is firs i have a variable Pctitbis that gose to the constant 0.01, to that result i must multip. it with "monto", then its result must be rounded to use 2 decimal positions.i need the round to work on all the values.Life is short get a rest and go out with some chiks :P |
 |
|
|
|
|
|
|
|