diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index e033650b74fe503c73f75b95acdc0e466a241e9a..3dc89cb196986d0be76a4e5430873c5f859fed9d 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -4870,7 +4870,8 @@ static void elapsedFinalizer(SQLFunctionCtx *pCtx) { } SElapsedInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - *(double *)pCtx->pOutput = (double)pInfo->max - (double)pInfo->min; + double result = (double)pInfo->max - (double)pInfo->min; + *(double *)pCtx->pOutput = result >= 0 ? result : -result; if (pCtx->numOfParams > 0 && pCtx->param[0].i64 > 0) { *(double *)pCtx->pOutput = *(double *)pCtx->pOutput / pCtx->param[0].i64; }