Select * from (
Select t. *,
The case when the exists (select 1 from (
Select id_number trunc (physical_date) as physical_date, count (1) as the from CNT tb_ld_main
Where is_used=1 and is_free=1 group by id_number, trunc (physical_date)
) where k k.i d_number=t.i d_number
And t.p hysical_date between add_months (k.p hysical_date - 11) and add_months (k.p hysical_date, 11)
And k.p hysical_date & lt;> T.p hysical_date
) then one else 0 end isrepeat
The from (
Select id_number trunc (physical_date) as physical_date, count (1) as the from CNT tb_ld_main
Where is_used=1 and is_free=1 group by id_number, trunc (physical_date)
) t
) g where g.i srepeat=1)
Select * from tb_ld_main m where the exists (select 1 from tb_temp p where m.i d_number=p.i d_number)
CodePudding user response:
Select * from based the where statement date=(select Max (date) from the statement)