# mes.spGetOEEDataByIntervalGroupByItemAndShift

## Description
This procedure returns Overall Equipment Effectiveness (OEE) metrics grouped by both item and operational shift for a specified asset over a given time interval. It aligns asset run/downtime with shift windows and aggregates counter data to compute availability, performance, quality, and OEE.

## Syntax
<b>mes.spGetOEEDataByIntervalGroupByItemAndShift @assetId, @startDate, @endDate, @interval</b><br /><br />

<b>Parameters:</b><br />
@assetId (int): ID of the asset to analyze.<br />
@startDate, @endDate (datetime): Date/time boundaries for analysis.<br />
@interval (varchar): Time granularity for the metrics ('Hour', 'Day', or 'Week').<br /><br />

<b>Returns:</b><br />
Rows grouped by shift and item with:<br />
- Shift ID and name<br />
- Item metadata (ID, name, units, packaging)<br />
- Duration, runtime, and downtime (planned/unplanned)<br />
- Raw and normalized infeed/outfeed/waste counters<br />
- Computed values: target count, availability, performance, quality, and OEE

### Code Example

```sql
EXEC mes.spGetOEEDataByIntervalGroupByItemAndShift
    @assetId = 3072,
    @startDate = '2025-07-01',
    @endDate = '2025-07-15',
    @interval = 'Day';
