Oracle Apex 20.1 根据整体项目状态将状态设置为 'Fullfilled' 或 'Pending'

Oracle Apex 20.1 Set Status to 'Fullfilled' or 'Pending' based on overall project status

在我的 table 中,我有一个项目专栏,它可以有多个项目里程碑(第二栏)。每个里程碑的值可以是 'fullfilled' 或 'pending' 作为 current_status(第三列)。现在我想汇总每个项目的总体状态并为其分配最终状态(新虚拟列)以便更好地概览。

应适用以下规则:

意思是我想检查每个项目的每个当前状态以获得 final_status。

知道如何使用 case-when-clause 或类似的东西来做到这一点吗?

谢谢。

亲切的问候。

如果只有两个状态,则检查是否只有'finished'.

第 1 - 9 行中的示例数据:

  • 项目 1 已完成,因为它的所有里程碑状态都是“已完成”
  • 项目 2 仍处于暂停状态,因为只有里程碑“已完成”

SQL> with project (projno, mileno, milestatus) as
  2    (select 1, 1, 'fulfilled' from dual union all
  3     select 1, 2, 'fulfilled' from dual union all
  4     select 1, 3, 'fulfilled' from dual union all
  5     --
  6     select 2, 1, 'fulfilled' from dual union all
  7     select 2, 2, 'pending'   from dual union all
  8     select 2, 3, 'pending'   from dual
  9    )
 10  select projno,
 11    case when min_status = max_status and
 12              max_status = 'fulfilled'
 13         then 'Finished'
 14    else 'On hold'
 15    end project_status
 16  from (select projno,
 17          min(milestatus) min_status,
 18          max(milestatus) max_status
 19        from project
 20        group by projno
 21       );

    PROJNO PROJECT_
---------- --------
         1 Finished
         2 On hold

SQL>