KL_Hutchmfg
IS-IT--Management
Hello,
I have a Sql query that currently shows me the last 6 weeks of rolling information. I need to change that report to show me the sum of the last 6 months of data.
I am extremely new at SQL and have been trying to find some things online but not sure where or how to get the "sum" of all the data and not just the return date of what happened 6 months ago. Hoping someone help. Here is what the current part has for each week:
(select lmlTimecardID from TimecardLines where datepart(ww,lmlActualEndTime) = datepart(ww,Getdate()) -5 and datepart(yy,lmlActualEndTime) = datepart(yy,Getdate()) and lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID and
lmlTimecardID = (select top 1 lmlTimecardID from TimecardLines where lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID Order By lmlActualEndTime desc))
group by jmoWorkCenterID) as WK6 on WK6WC = xawWorkCenterID
How can I rewrite this to pull the entire 6 month period without specific date ranges.
I have a Sql query that currently shows me the last 6 weeks of rolling information. I need to change that report to show me the sum of the last 6 months of data.
I am extremely new at SQL and have been trying to find some things online but not sure where or how to get the "sum" of all the data and not just the return date of what happened 6 months ago. Hoping someone help. Here is what the current part has for each week:
(select lmlTimecardID from TimecardLines where datepart(ww,lmlActualEndTime) = datepart(ww,Getdate()) -5 and datepart(yy,lmlActualEndTime) = datepart(yy,Getdate()) and lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID and
lmlTimecardID = (select top 1 lmlTimecardID from TimecardLines where lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID Order By lmlActualEndTime desc))
group by jmoWorkCenterID) as WK6 on WK6WC = xawWorkCenterID
How can I rewrite this to pull the entire 6 month period without specific date ranges.