gpt4 book ai didi

sql - 简单的 SQL 查询 : need this month data and previous month last 5 days data together

转载 作者:行者123 更新时间:2023-12-04 21:02:24 25 4
gpt4 key购买 nike

需要同时查询本月数据和上月最近5天数据的SQL:

SELECT
CONVERT(VARCHAR (10), wDate, 103) AS wDate,
Empid,
Process,
Model,
Qty,
Section,
Avlbl_Mins,
NP_Mins,
L_Mins,
NP_Reason AS NPReason,
Process_Remarks AS PRem,
Day_Remarks AS DRem,
Othermin,
StdMin,
Tstdmin,
TAvlblmin
FROM tblProductionEffcyDetails
WHERE (DAY(EnteredDate) >= DAY(GETDATE()) - 5)
ORDER BY EnteredDate DESC

最佳答案

试试这个:获取上个月过去五天的数据

WHERE EnteredDate > (DATEADD(DAY,-5,DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0))

关于sql - 简单的 SQL 查询 : need this month data and previous month last 5 days data together,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40101636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com