diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index e989c91efc950e0a31c310d12b38cd90a4ed0a00..a4bfa4f38f864a34339cd301c08445b46b3b8904 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -1094,7 +1094,6 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { { if (pAggInfo->hasDataBlockForNewGroup) { - pAggInfo->binfo.pRes->info.rows = 0; pAggInfo->hasPrev = false; // now we start from a new group data set. // not belongs to the same group, return the result of current group; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 42ab37111b389faa5225181f63d8454ad94c1df3..3092a29e96f51b19671361c7c95e971bfe1c9564 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -4578,9 +4578,12 @@ SArray* getOrderCheckColumns(SQueryAttr* pQuery) { for(int32_t i = 0; i < numOfCols; ++i) { SColIndex* index = taosArrayGet(pOrderColumns, i); for(int32_t j = 0; j < pQuery->numOfOutput; ++j) { - if (index->colId == pQuery->pExpr1[j].base.colInfo.colId) { + SSqlExpr* pExpr = &pQuery->pExpr1[j].base; + int32_t functionId = pExpr->functionId; + + if (index->colId == pExpr->colInfo.colId && (functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAG)) { index->colIndex = j; - index->colId = pQuery->pExpr1[j].base.resColId; + index->colId = pExpr->resColId; } } }