日期:2014-05-17 浏览次数:20605 次
;with cte as( select * from contractTable a join propertyTable b on a.city+a.road+a.address=b.city+b.road+b.address ) select * from cte a where not exists(select 1 from cte where city=a.city and road=a.road and address=a.address and leasedateto>a.leasedateto)
;with cte as(
select *
from contractTable a join propertyTable b on a.city+a.road+a.address=b.city+b.road+b.address
) --- 在cte里把需要的列名别名出来 再查询
select * from cte a where not exists(select 1 from cte where city=a.city and road=a.road and address=a.address and leasedateto>a.leasedateto)