Oracle Query将2000转换为20.00

时间:2019-07-08 06:15:20

标签: sql oracle

我的oracle数据库中有一个数字4000,我必须将其转换为20.00并将其插入另一个。请帮助我如何使用oracle查询执行此操作。

2 个答案:

答案 0 :(得分:2)

您在下面找到了什么

public class DerivedMain {

int data = 10;

@Override
public int hashCode() {
    return data;
}

public static void main(String[] args) {

    HashMap m = new HashMap();
    for(int i=0;i<20;i++) {
        m.put(i, i);
    }

    Field tableField = null;
    try {
        tableField = HashMap.class.getDeclaredField("table");
    } catch (NoSuchFieldException | SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    tableField.setAccessible(true);
    Object[] table = null;
    try {
        table = (Object[]) tableField.get(m);
    } catch (IllegalArgumentException | IllegalAccessException e) 
            {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println(table == null ? 0 : table.length);
}

答案 1 :(得分:0)

要保留小数点,看起来目标列的数据类型为VARCHAR2,这意味着TO_CHAR函数(以及适当的格式掩码)可能会有所帮助。这是一个示例:

SQL> create table source (num number);

Table created.

SQL> insert into source (num)
  2    select 2000 from dual union all
  3    select 400  from dual union all
  4    select 5    from dual;

3 rows created.

SQL> create table target (cchar varchar2(20));

Table created.

SQL> insert into target (cchar)
  2    select to_char(num/100, '999G990D00')
  3    from source;

3 rows created.

SQL> select * from target;

CCHAR
--------------------
      20,00
       4,00
       0,05

SQL>