这是真的吗 ?

我想在此表中插入“valname”字符串列,该字符串将按随机顺序为(USD,EUR,RUB)10000次。

在第二列“金额”中
插入100-2000之间的随机数。 (10000次)

在3D列中
“应该”代表乘法量的结果
(如果USD * 69)(如果EUR
* 72)(如果卢布* 1.2)

例如

valname = USD, ammount = 100, converted_ammount = 6900;
valname = EUR, ammount = 100, converted_ammount = 7200;
valname = RUB, ammount = 100,converted_ammount = 120;

按级别
    CREATE table t_test01 (    valname varchar2(5),
ammount number null,    converted_ammount number null --- by multiplication
    * 69,72,1.2    )

最佳答案

insert into t_test01
 with x as (select case trunc(dbms_random.value*3)
                     when 0 then 'EUR'
                     when 1 then 'USD'
                     else 'RUB' end currency,
             round(dbms_random.value(100,2000)) ammount
             from dual connect by rownum<=10000)
  select currency, ammount,
         ammount* case currency
            when 'USD' then 69
            when 'EUR' then 72
            else 1.2 end converted_ammount
    from x;

10-06 01:21