You are here: Re: Unexpected Casting With Sum & Coalesce « MsSQL Server « IT news, forums, messages
Re: Unexpected Casting With Sum & Coalesce

Posted by Hugo Kornelis on 09/25/08 11:59

On Thu, 28 Sep 2006 20:37:33 GMT, Don wrote:

>If I have an SQL query which returns an aggregate of several decimal fields
>like so:
>
> (sum(COALESCE(myDecimal1, 0)+
> sum(COALESCE(myDecimal2, 0)+
> sum(COALESCE(myDecimal3, 0)) as MyTotal
>
>I get an rounded integer in MyTotal.
>
>However, if I do the following:
>
> sum(COALESCE(myDecimal1, 0)+
> COALESCE(myDecimal1, 0)+
> COALESCE(myDecimal1, 0)) as MyTotal
>
>I get a (proper) decimal value.
>
>
>Does anyone know why the first case returns an Integer?

Hi Don,

Can you please post a full repro script? (That is, post CREATE TABLE
statements, INSERT statements and SELECT statements to reproduce this
behaviour in an empty database).

--
Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация