# mes.fnGetCount

## Description
Returns the sum of counter values for a given counter Id within a time range.

## Syntax
  <b>mes.fnGetCount(@rangeStart, @rangeEnd, @counterId)</b>  
  <br /><br />
  <b>Parameters:</b><br />
  <li>@rangeStart (datetime): Start of the time range</li>
  <li>@rangeEnd (datetime): End of the time range (nullable; defaults to current time)</li>
  <li>@counterId (int): Id of the counter</li>
  <br />
  <b>Returns:</b><br />
  <li>float: Sum of counter values</li>

### Example Code:

```sql
SELECT mes.fnGetCount(
  '2025-07-01T00:00:00', 
  '2025-07-30T00:00:00', 
  1012
) AS total_count;
