我的业务逻辑是:
客户投诉表A: complaintdate;
日历表B:calendardate (有节假日设定),status :1 工作日;2:周末;3:国定假日;
我想查询表A 中的complaintdate的日期与当前日期相比,超过5个工作日的数据查出来;怎么写这样的sql?
客户投诉表A: complaintdate;
日历表B:calendardate (有节假日设定),status :1 工作日;2:周末;3:国定假日;
我想查询表A 中的complaintdate的日期与当前日期相比,超过5个工作日的数据查出来;怎么写这样的sql?
from A a,B b
having DATEDIFF(DD,a.complaintdate,GETDATE())>5
SELECT * FROM A WHERE (having DATEDIFF(DD,complaintdate,GETDATE())-
SELECT COUNT(1) FROM B WHERE status IN(2,3) AND calendardate BETWEEN A.complaintdate AND GETDATE())>5