I am generating a report which displays how long the plant was running for the day.
Since the operator shuts down the system at lunchtime, I have 2 records for the plant operation hours for each day. I want to display only one record that contains the production Start Time (6:00 am) and production End Time (around 4:00 pm). I have got a table Runtime_Combined
that has an auto-incrementing index.
I want to select start date (e.g. 9/1/2021 6:04 AM
, which has runtime_combined_ndx
= 1) and end date (e.g. 9/1/21 4:23 PM
, which has runtime_combined_ndx
= 2).
SELECT ProductionStartDate, ProductionEndDate
FROM Runtime_Combined
WHERE month(ProductionStartDate) = month (ProductionStartDate)
And day(ProductionStartDate) = day( ProductionStartDate)
You can use aggregation: