# mes.spGetAssetStateDataSummary

## Description
Returns a summarized breakdown of state durations for a given asset over a specified time range. Each row represents time spent in a specific state, categorized by state type, color, and label. Adjusts the start of the range to capture partial states that began prior to the provided window.

## Syntax
<b>mes.spGetAssetStateDataSummary @assetId, @rangeStart, @rangeEnd</b>  
<br /><br />

<b>Parameters:</b><br />
@assetId (int): Asset whose state data is being summarized.<br />
@rangeStart (datetime): Lower bound of the time window to analyze.<br />
@rangeEnd (datetime): Upper bound of the time window to analyze.<br /><br />

<b>Returns:</b><br />
- assetPath: Full hierarchical path of the asset.<br />
- assetName: Name of the asset.<br />
- stateName: Name of the state, optionally prefixed with asset name for cross-asset references.<br />
- stateTypeName: Logical category of the state (e.g., Running, Planned Downtime).<br />
- stateTypeColor: Hex color representing the state type.<br />
- durationSecs: Total seconds spent in this state across the range.<br />

### Code Example

```sql
-- Get a breakdown of state durations by state type for asset 3010
EXEC mes.spGetAssetStateDataSummary 
     @assetId = 3010, 
     @rangeStart = '2025-06-01', 
     @rangeEnd = '2025-06-30';
