English 中文(简体)
Sqlite将案文改为 de?
原标题:Sqlite convert text to decimal?

页: 1

在一栏中,以这种格式储存美元价值:1.01美元、40.58美元等。

I m 试图用美元价值加起来

SELECT SUM(amount) FROM record WHERE date LIKE  "+date+" "

然而,这并不奏效,大概是因为你可以增加案文。 我知道,这是理想的储存,但我会如何分配数额,以便我能够补充这些数额?

最佳回答

诚然,正如你所说的那样,这远非储存价值的理想方式(从一开始就应在<条码>标准/代码>/<代码>real格式上)。

SELECT SUM(SUBSTR(amount, 2)) FROM record WHERE date LIKE  "+date+" "

<代码>SUBSTR方法是一种文字功能,将包含案文的一个部分(在这种情况下,从一个起点指数)。 这里的问题是<条码><美元/代码>签字,这混淆了动态类型转换成认为你正在尝试加插。

现在应当做的是,作为Lite允许的dynamic打。 (以斜体表示,该数值用于比较,而不是集装箱)。

问题回答

储存“unpld integers”等值的工作做得更好,如果需要显示,就应当加以编排。 你们的储存更加紧凑,并且更容易和更快地增加。 使用惯性避免在浮动点代表中出现四舍五入错误的风险。

uncald,我指的是12.3美元将作为第123卷储存。 (Use long in You Java Code, and INTEERT in the Prof.)

You:

// implement this any way you like!
long         amount   = getAmountFromDb();    

// use default locale if you want
Locale       locale       = getLocaleFromSomewhere();                 
Currency     currency     = Currency.getInstance(locale);
NumberFormat format       = NumberFormat.getCurrencyInstance(locale);
int          scale        = currency.getDefaultFractionDigits();

BigDecimal   scaledAmount = new BigDecimal(unscaledBalance).movePointLeft(scale);
String       textAmount   = format.format(scaledAmount);




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签