【发布时间】:2019-05-29 12:18:14
【问题描述】:
我有一个下面的查询,它正在工作,但对于同一属性 ROADLOG/HPMS,NRLG_SMAINT 的某些属性不是 Y,我想删除重复的行。我不介意任何 NRLG_SMAINT 属性不是 Y,但如果是 Y,我不希望该行显示为相同的 ROADLOG/HPMS 属性,其中有 Y。查询如下:
select t.nrlg_dept_route || t.nrlg_dept_roadbed as roadlog,s.HPMS,t.nrlg_smaint
from TIS.TIS_NEW_ROADLOG t right join HPMS_DATA s
on t.nrlg_dept_route || t.nrlg_dept_roadbed = s.hpms
group by t.nrlg_dept_route || t.nrlg_dept_roadbed,s.HPMS,t.nrlg_smaint
order by 1
这是迄今为止的输出示例:
ROADLOG HPMS NRLG_SMAINT
85 C001821N C001821N
86 C001992N C001992N
87 C005201N C005201N Y
88 C005201N C005201N --- remove this row
89 C005202E C005202E Y
90 C005202E C005202E --- remove this row
91 C005203N C005203N Y
92 C005203N C005203N --- remove this row
93 C005205N C005205N Y
94 C005205N C005205N
95 C005207S C005207S --- leave this row
96 C005208N C005208N Y
97 C005208N C005208N
98 C005209N C005209N Y
99 C005209N C005209N
【问题讨论】:
-
第 94 行和第 99 行呢?
-
您将删除第 94,97 和 99 行。我只是放入离开行并删除行文本以帮助说明这一点。但留下 85,86。
标签: sql oracle11g plsqldeveloper