with tb_temp as (
select * from(
select t.*,
case when exists(select 1 from (
select id_number,trunc(physical_date) as physical_date,count(1) as cnt from tb_ld_main
where is_used=1 and is_free=1 group by id_number,trunc(physical_date)
) k where k.id_number=t.id_number
and t.physical_date between add_months(k.physical_date,-11) and add_months(k.physical_date,11)
and k.physical_date<>t.physical_date
) then 1 else 0 end isrepeat
from (
select id_number,trunc(physical_date) as physical_date,count(1) as cnt from tb_ld_main
where is_used=1 and is_free=1 group by id_number,trunc(physical_date)
) t
) g where g.isrepeat=1 )
select * from tb_ld_main m where exists(select 1 from tb_temp p where m.id_number=p.id_number)
uj5u.com熱心網友回復:
select * from 陳述句基礎 where 日期 = (select max(日期) from 陳述句基礎)轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/284991.html
標籤:基礎和管理