首页 > 解决方案 > 合并 Apex 报告中的两列

问题描述

我的报告中有两列:金额和货币,而不是在单独的列中显示每一列我想在一列中显示货币旁边的金额我知道我可以在 SQL 中使用:

select amount||currency_id from my_table

或(因为货币列是共享组件)

select amount||currency from my_table, currency_table
where my_table.currency_id = currency_table.currency_id

那么有没有办法合并它们或SQL代码是唯一的方法?

标签: htmlsqloracleoracle-apex

解决方案


编写SQL的正确方法是:

select t.amount || c.currency
from my_table t join
     currency_table c
     on t.currency_id = c.currency_id;

笔记:

  • 切勿FROM子句中使用逗号。
  • 始终使用正确、明确、标准、可读的JOIN语法。
  • 限定查询中的列引用,以便您知道列的来源。
  • 使用表别名,因此查询更易于编写和阅读。

推荐阅读