这里的人都这么势利呢?不见分就不回答,还是我来。
delete from newCar a
left join (select Licence_ID,max(CreateDate) from newCar where b.Licence_ID=null group by Licence_ID having count(*)>1) b on a.Licence_ID=b.Licence_ID and a.CreateDate=b.CreateDate
where a.Budget_ID != null and b.Licence_ID=null
delete from newCar a
left join (select Licence_ID,max(CreateDate) from newCar where b.Licence_ID=null group by Licence_ID having count(*)>1) b on a.Licence_ID=b.Licence_ID and a.CreateDate=b.CreateDate
where a.Budget_ID != null and b.Licence_ID=null
delete newCar from newCar a
left join (select Licence_ID,max(CreateDate) from newCar where b.Licence_ID=null group by Licence_ID having count(*)>1) b on a.Licence_ID=b.Licence_ID and a.CreateDate=b.CreateDate
where a.Budget_ID not is null and b.Licence_ID is null
delete newCar from newCar a
left join (select Licence_ID,max(CreateDate) from newCar where b.Licence_ID not is null group by Licence_ID having count(*)>1) b on a.Licence_ID=b.Licence_ID and a.CreateDate=b.CreateDate
where a.Budget_ID not is null and b.Licence_ID is nullnull不能用'='或者'!='进行判断。
delete newCar from newCar a
left join (select Licence_ID,max(CreateDate) from newCar where b.Licence_ID not is null group by Licence_ID having count(*)>1) b on a.Licence_ID=b.Licence_ID and a.CreateDate=b.CreateDate
where a.Budget_ID not is null and b.Licence_ID is null and a.Licence_ID in(select Licence_ID from newCar group by Licence_ID having count(*)>1)
insert gggs select 1,'2006-06-05',234
insert gggs select 1,'2006-09-02',32
insert gggs select 2,'2006-09-07',432
insert gggs select 2,'2006-09-14',nulldelete from gggs where
exists(select 1 from gggs a where a.Licence_ID=gggs.Licence_ID and a.CreateDate>gggs.CreateDate and Budget_ID is not null) or Budget_ID is null
select * from gggs