Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #555

Proper way to get decimal results from arithmetic with integers and decimals

From BobRoyAce <broy@omegasoftwareinc.com>
Newsgroups comp.databases.ms-sqlserver
Subject Proper way to get decimal results from arithmetic with integers and decimals
Date 2011-07-20 21:36 -0700
Organization http://groups.google.com
Message-ID <ea0bbf58-8d97-40f0-aa30-efbb667237f4@f20g2000yqm.googlegroups.com> (permalink)

Show all headers | View raw


Let's say that I have a table with two fields: InfPctField and
DecimalField, where the first is of type INT and the latter is
DECIMAL(16,2).

When I write a query as...

SELECT DecimalField * IntPctField / 100. AS TheAnswer

TheAnswer comes back as ZERO followed by decimals, with all decimal
digits ZEROs (e.g. 0.00000).

What is the correct syntax to get back nonzero values?

For example, when DecimalField is 1200.00 and IntPctField is 30, I
should get 360.00.

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

Proper way to get decimal results from arithmetic with integers and decimals BobRoyAce <broy@omegasoftwareinc.com> - 2011-07-20 21:36 -0700
  Re: Proper way to get decimal results from arithmetic with integers and decimals Henk van den Berg <me@myplace.net> - 2011-07-21 09:23 +0200
    Re: Proper way to get decimal results from arithmetic with integers and decimals BobRoyAce <broy@omegasoftwareinc.com> - 2011-07-22 00:08 -0700

csiph-web