Oracle apex Oracle Apex中的计算有问题吗?

Oracle apex Oracle Apex中的计算有问题吗?,oracle-apex,calculation,Oracle Apex,Calculation,我有两张桌子:账单和产品。表product中有产品的属性价格,表bill中有数量和总价属性。因此,我需要将产品的属性价格和账单的数量相乘来计算属性总价。有人知道怎么做吗?不知何故,我怀疑那些表只包含您提到的列。他们都缺少某种类型的ID,这使得加入成为可能。否则,这就没有意义了 例如(连同一些示例数据): 要设置总价列值,可以使用更新 SQL> update bill b set 2 b.total_price = (select b.quantity * p.price 3

我有两张桌子:账单和产品。表product中有产品的属性价格,表bill中有数量和总价属性。因此,我需要将产品的属性价格和账单的数量相乘来计算属性总价。有人知道怎么做吗?

不知何故,我怀疑那些表只包含您提到的列。他们都缺少某种类型的
ID
,这使得加入成为可能。否则,这就没有意义了

例如(连同一些示例数据):

要设置
总价
列值,可以使用
更新

SQL> update bill b set
  2    b.total_price = (select b.quantity * p.price
  3                     from product p
  4                     where p.product_id = b.product_id
  5                    );

1 row updated.

SQL> select * From bill;

PRODUCT_ID   QUANTITY TOTAL_PRICE
---------- ---------- -----------
         1          5         500

SQL> rollback;

Rollback complete.
合并

SQL> merge into bill b
  2    using (select p.product_id, p.price
  3           from product p
  4          ) x
  5    on (b.product_id = x.product_id)
  6  when matched then update set b.total_price = b.quantity * x.price;

1 row merged.

SQL> select * From bill;

PRODUCT_ID   QUANTITY TOTAL_PRICE
---------- ---------- -----------
         1          5         500
当你用一个顶点标记这个问题时,你不清楚你到底有什么。这是什么样的页面?如果它是一个报告(经典或交互式),您可以将
product\u id
上的表作为

SQL> select b.product_id, b.quantity, p.price, b.quantity * p.price as total_price
  2  from product p join bill b on b.product_id = p.product_id;

PRODUCT_ID   QUANTITY      PRICE TOTAL_PRICE
---------- ---------- ---------- -----------
         1          5        100         500
如果是表单页面,则使用动态操作,在更改
P1\u价格
和/或
P1\u数量
时设置值;假设它是第1页,那么您将
P1\u总价
设置为

:P1_PRICE * :P1_QUANTITY
基本上,有很多选择。你要用的那个取决于你真正拥有什么

:P1_PRICE * :P1_QUANTITY