Showing posts with label decimal. Show all posts
Showing posts with label decimal. Show all posts

Monday, March 12, 2012

Qty - decimal, money, or ...

which data type will be the best for the qty column?
- RDepends on the actual values. What kind of values do you expect?
ML
http://milambda.blogspot.com/|||Precision should have been specified in a requirements document. If that's
what you're working on, then you need to consider what things are to be
quantified. Are they inventory items that are purchased and sold in
individual packages? Are they purchased or sold by weight? By volume?
Remember that if you use a float data type that you must account for
rounding errors in calculations, which usually involves adding additional
code and invites the possibility that a programmer will fail to add that
code.
"Rock" <Rock@.discussions.microsoft.com> wrote in message
news:3F994D97-A01B-48B2-B555-510FF25A9DF2@.microsoft.com...
> which data type will be the best for the qty column?
> - R|||On Fri, 17 Feb 2006 01:30:27 -0800, "Rock"
<Rock@.discussions.microsoft.com> wrote:

>which data type will be the best for the qty column?
>- R
If it is always a whole number 3, 1534, 65432, then I use the
appropriately sized version of Int (generally int, possibly bigint).
If it is a decimal fraction of known size, say 145.75 I would use
Decimal.
If it is a decimal fraction that has to be more flexible, then float
may be required, but take Brian's warning to heart if you go that way.
Roy

Friday, March 9, 2012

QA returning negative #s as positive

Hey guys,

I have a very peculiar issue going on. I have a table that contains a decimal(18,2) column called "Amount". Looking at this table through Enterprise Mgr, I can see that there are values in there that are negative. However, when I run a query in Query Analyzer, it displays all the negative values as positives.

The only workaround I've found right now is to change the column type to "real" and then change it back to decimal(18,2), and it starts showing the negatives as negative. However, without performing this absurd workaround, it doesn't work.

Is there a known bug in QA that would manifest itself as this? What is the cause for this?

Thanks in advance.I haven't had a problem with this. What does your query look like? Are the correct results being retuned to your ASP.NET application?

Terri|||Terri,

The query is a straight forward select, nothing tricky at all. Basically, if I look at the Amount values through the analyzer, it displays them as positive. However, one interesting to note is that it recognizes the number as being negative because if i add another column to the return so that it's "Amount * 1", it will return the correct (negative) value.

It basically seems to be a displaying issue. I google'd this issue, and came across a few posts from other forums where people were having the same issue, but none of the threads had an explanation.

Also, this is a problem only with this table. There are other tables in the warehouse that have decimal(18,2) columns with negative values, and they get displayed correctly. At the same time, though, there's nothing special about the table in question. The amount column is sourced from a different table with a column of number(21,6) type, which is really a glorified decimal, so that doesn't seem to be the problem.

I'm pretty much puzzled as to why this column would be displayed incorrectly like this. I welcome any suggestions/ideas.

Thanks|||Have you been able to resolve this issue? I have been out of town this past week and will jump back into this if you are still stuck.

Terri|||Hey Terri,

Actually, it's been sitting on the back burner, and I've been busy with other things. I would, ultimately, like to figure out what is happening, so if you have any ideas, I am all ears.

I did a search on Google groups, this forum, and a few others, and was unable to find an answer. I did find a few threads on various sources concerning this problem, but there was no resolution from anyone.

Thanks for the help.