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 |
ian.urquhart.fds
Starting Member
1 Post |
Posted - 2014-05-16 : 07:56:31
|
Hi There I have an issue where a query on a view is returning a value with too many decimal places The view in question is made up of a union of three views on three different databases The value on the individual views is a float and has been rounded with round(value,2)The query that were trying is something like SELECT sum(value) FROM overallview Where otherfield='someval'Someval here can be either of 10 values the odd thing is that in were only getting too many decimal places in one instance. the rest come out fine Any ideasMany thanks Ian |
|
adsingh82
Starting Member
20 Posts |
Posted - 2014-05-19 : 05:55:45
|
Normally union all will get the higher available size of the value so you are getting too many decimal places, You can cast the result sum value into two decimal places. SELECT CAST(sum(value) AS decimal(18, 2)) FROM overallview WHERE otherfield='someval' Regards,Alwyn.M |
|
|
|
|
|