当前位置:网站首页>SQLserver加个判断

SQLserver加个判断

2022-08-10 01:39:00 CSDN问答

SELECT count(distinct lp.lot_number)as ELzs
FROM (SELECT lp.lot_number,lp.TransDate,lp.WorkorderId ,lp.device_number,
ROW_NUMBER() OVER( PARTITION BY lp.lot_number ORDER BY lp.TransDate)RN FROM Lot_Process lp)lp
WHERE RN=2 and (lp.WorkorderId like'PB%' or lp.WorkorderId like'DB%') and
lp.device_number in('M1-EL1-L1-01','M1-EL1-L1-02')
and lp.TransDate between convert(varchar(11),dateadd(day,-1,getdate()),120)+'08:00:00'
and convert(varchar(11),dateadd(day,-1,getdate()),120)+'19:59:59'

给帮忙加个判断,每天9点之前查询昨天8点到昨天20点,9点之后查询今天8点到今天20点。

原网站

版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7767090