如何加入 Apex oracle
How to make join in Apex oracle
哇哇哇
请帮我完成作业
我有 2 个 table :
-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
``
如您所愿,它看起来像是一系列 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>
哇哇哇
请帮我完成作业
我有 2 个 table :
-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
``
如您所愿,它看起来像是一系列 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>