如何加入 Apex oracle
Posted
技术标签:
【中文标题】如何加入 Apex oracle【英文标题】:How to make join in Apex oracle 【发布时间】:2020-05-13 07:51:59 【问题描述】:嘿嘿嘿
请帮我完成我的任务
我有 2 张桌子:
-Nasabah (id,name,address).
-Transaksi_Nasabah (id,nominal,date,kategori,id_nasabah)
在类别中有 2 个值(存款和取款)
ID NOMINAL DATE KATEGORI ID_NASABAH
3 100000 03/02/2020 Deposit 3
5 100000 03/02/2020 Deposit 5
4 100000 03/02/2020 Deposit 4
7 10000 03/09/2020 Deposit 1
13 50000 03/11/2020 Withdtawal 2
14 25000 03/16/2020 Deposit 3
......................................... etc
我必须做
total deposit 760000
total withdrawal 130000
Saldo (Deposit-WD) 630000
MAX Deposit 100000
Min Deposit 5000
Max Withdrawal 50000
Min Withdrawal 10000
``
【问题讨论】:
【参考方案1】:按照你想要的方式,它看起来像一系列 UNION
ed select
语句,例如
SQL> with test (nominal, kategori) as
2 (select 100, 'Deposit' from dual union all
3 select 200, 'Deposit' from dual union all
4 select 50, 'Withdrawal' from dual union all
5 select 30, 'Withdrawal' from dual
6 )
7 select 'total deposit' what , sum(nominal) result from test where kategori = 'Deposit'
8 union all
9 select 'total withdrawal' , sum(nominal) from test where kategori = 'Withdrawal'
10 union all
11 select 'saldo (deposit - wd)', sum(case when kategori = 'Deposit' then nominal
12 when kategori = 'Withdrawal' then -nominal
13 end
14 )
15 from test
16 union all
17 select 'max deposit' , max(nominal) from test where kategori = 'Deposit';
WHAT RESULT
-------------------- ----------
total deposit 300
total withdrawal 80
saldo (deposit - wd) 220
max deposit 200
SQL>
【讨论】:
不客气。我编辑了我的答案并添加了“实时示例”来展示如何做到这一点。 SALDO 从第 11 行开始。以上是关于如何加入 Apex oracle的主要内容,如果未能解决你的问题,请参考以下文章
如何仅使用 sql 在 apex oracle 的交互式网格中实现选择列表以及 oracle APEX 中可用的内容?
如何获取 Oracle APEX 文本字段值(现在我得到的都是 NULL)(Oracle APEX Application Express 21.1)