条件查询带去重

查询条件查询条件去重

select * from t_order_smthkMain s
where 1=1 and not exists
(
select 1 from t_order_smthkMain where PlanCode=s.PlanCode and
dateadd(hh,Time,AddDate)>dateadd(hh,s.Time,s.AddDate)
)

日期与小时的相加
时间(datetime类型).addhours(小时(int类型))

数据库中则为

dateadd(hh,时长(几个小时)),日期(年月日时分秒))

原文地址:https://www.cnblogs.com/ykgbk/p/13099391.html