You are here: Re: Query Help, thanks! « MsSQL Server « IT news, forums, messages
Re: Query Help, thanks!

Posted by Simon Hayes on 09/30/05 01:05

David Portas wrote:
>>create table a
>> (account int
>> ,balance_date datetime
>> ,balance money)
>
>
>
> Why are all your columns nullable? What is/are the key/s of this table?
> Are you aware that MONEY will give you imprecisely rounded results when
> you multiply or divide?
>
> Try:
>
> SELECT account, balance_date, balance
> FROM a AS T
> WHERE balance_date =
> (SELECT MAX(balance_date)
> FROM a
> WHERE account = T.account) ;
>

David,

Are you channelling Celko? :-) Whether or not the columns are NULL or
NOT NULL depends on ANSI_NULL_DFLT_ON/OFF - admittedly, they will be
NULL by default most of the time.

As for money, what data type should an amount of money be; money in
MSSQL is is essentially decimal(19,4), which is a precise data type (and
specifically recommended by BOL for cases where precision is required).
Ignoring the nonsense with currency symbols which MSSQL allows, and
forgetting about currencies like the old Turkish Lira (where dec(24,4)
or more might be needed in certain industries), why would there be any
reason to believe that results will be imprecise?

Simon

 

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

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