#2
yiyanxiyin2023-07-06 13:21
|
select a.* from
(select distinct htno,c_value,row_number()over(partition by htno order by samply_no desc) rn from BGTAMODLL3.T_ODS_TQMTJ04 where rec_creator='100' and c_value>0 and c_value<20) a
where a.rn='1'
union all
select * from
(select distinct htno,c_value as dc_c,row_number()over(partition by htno order by sample_time desc) rn from BGTAMODLL3.T_ODS_TMMSM35 where htno not in (select distinct htno from a) and c_value>0 and c_value<1)
where rn='1'
order by htno
问题出在第二段程序 htno not in (select distinct htno from a) 这个地方,这个去掉程序可以实现,主要是第二个程序的htno和第一段是相关的,这种情况要怎么处理才能让两个表并在一起。