Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Kecualikan item menurut catatan

create table #resource
(
    DPTID varchar(10)
    ,FISCAL_YEAR varchar(10)
    ,OPERATING_UNIT varchar(10)
    ,AMOUNT int
)

insert into #resource
select 'PTT','2017','WP', 1200 union all
select 'PTT','2017','SP', 3000 union all
select 'PTT','2017','GP', 1000 union all
select 'FPP','2017','WP', 1000 union all
select 'FPP','2018','GP', 2000 union all
select 'FPP','2017','SP', 1000 union all
select 'FPP','2018','SP', 2000

select * from #resource

select FISCAL_YEAR,DPTID, SUM(AMOUNT) as Amount
from #resource
where OPERATING_UNIT <> 'WP'
group by FISCAL_YEAR,DPTID
order by FISCAL_YEAR,Amount desc


drop table #resource

keluaran:

FISCAL_YEAR DPTID   Amount
2017        PTT     4000
2017        FPP     1000
2018        FPP     4000


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. SQL tidak sama &null

  2. pl/sql Stored procedure... kemana waktu eksekusinya?

  3. Apakah ada alasan untuk menggunakan kunci utama dan kunci unik bersama-sama di bidang yang sama?

  4. Oracle PL/SQL:DBMS_SCHEDULER.CREATE_JOB Contoh

  5. Bantuan Permintaan PL SQL Rekursif