首页 > 解决方案 > 创建 Oracle 数据库查询

问题描述

我有下表(tb1):

在此处输入图像描述

我需要创建一个包含以下内容的查询:

对于上表,此查询应返回下表:

在此处输入图像描述

谁能帮助我如何创建它?

标签: oracle

解决方案


最终查询:select q2.id,q2.PCR,q2.status, q2.date_created from (select pcr, min(date_created) date_created from table1 t1 where not exists (select * from table1 t2 where t1.pcr = t2.pcr and t2.status = '002') group by pcr) q1 inner join (select * from table1) q2 on q1.PCR = q2.PCR and q1.date_created = q2.date_created


推荐阅读