select a.* from grdksqb a inner join ( select distinct sqdh from tdsqb)b on a.sqdh=b.sqdh where 筛选条件
select * from (select *,rn=row_number() over (partition by sqdh order by getdate()) from grdksqb) a where rn=1 and exists(select * from tdsqb where sqdh=a.sqdh)
from grdksqb a inner join (
select distinct sqdh
from tdsqb)b on a.sqdh=b.sqdh
where 筛选条件
where rn=1 and exists(select * from tdsqb where sqdh=a.sqdh)