# mes.spGetAssetProductionEventSummary

## Description
Generates an aggregated summary of production events and performance metrics (OEE) for a given asset over a specified time window. Data is grouped by asset, mode, work order, and item, and includes summarized counters, durations, and calculated KPIs.

## Syntax
<b>mes.spGetAssetProductionEventSummary @assetId, @rangeStart, @rangeEnd, @modeId, @workOrderId, @strictDates</b>  
<br /><br />

<b>Parameters:</b><br />
@assetId (int): The asset for which to retrieve production data.<br />
@rangeStart (datetime): Lower bound of the time window to analyze (nullable).<br />
@rangeEnd (datetime): Upper bound of the time window to analyze (nullable).<br />
@modeId (int): Optional filter by mode ID.<br />
@workOrderId (int): Optional filter by work order ID.<br />
@strictDates (bit): Whether to strictly enforce the time window for mode durations.<br /><br />

<b>Returns:</b><br />
Aggregated table including:<br />
- Mode metadata and asset hierarchy<br />
- Work order and item information<br />
- Total runtime, downtime, production counts<br />
- Target OEE values<br />
- Calculated OEE metrics from fnGetOEEMetrics()

### Code Example

```sql
-- Return a summarized view of production performance over a time window
EXEC mes.spGetAssetProductionEventSummary 
     @assetId = 3031,
     @rangeStart = '2025-06-01',
     @rangeEnd = '2025-06-30',
     @modeId = NULL,
     @workOrderId = NULL,
     @strictDates = 1;
