Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c++连接,聚合函数(avg,sum)查询得到结果为0或接近0的值 #28882

Open
panicwq opened this issue Nov 22, 2024 · 0 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@panicwq
Copy link

panicwq commented Nov 22, 2024

版本3.0.5.1社区版本 win
在taos shell中一样的查询语句能查到对的平均值。
用C++连接taos,得到为0,但是其他普通查询可以得到正确数值,max()和min()也正确,只有avg()【聚合函数,测试sum()也为0,或者时很接近0的数】提取数值总是0。

关键代码:
`
QString data = QString("SELECT avg(fyfkqxz_yc02) as fyfkqxz_yc02_avg FROM tsdb.ycmain WHERE TIMEDIFF(ts,NOW)<120000 and ts<=NOW");

TAOS_RES* result = taos_query(taosCon, data.toUtf8().data());

TAOS_ROW    row = NULL;

int         num_fields = taos_field_count(result);
TAOS_FIELD* fields = taos_fetch_fields(result);

fprintf(stdout, "query successfully, got %d fields, the sql is: %s.\n", num_fields, data.toUtf8().data());

while ((row = taos_fetch_row(result)))
{
	if (num_fields > 0)
	{
		auto colname = fields[0].name;
		QString colN = colname;
		float statdata = *(float*)(row[0]);//0
		qDebug() << colN << statdata;
	}
}
taos_free_result(result);

`

taos shell中同样的语句查询正确
image

@panicwq panicwq added help wanted Extra attention is needed question Further information is requested labels Nov 22, 2024
@panicwq panicwq changed the title 3.0.51社区版本,c++连接,平均值查询总是0 3.0.5.1社区版本,c++连接,平均值查询总是0 Nov 22, 2024
@panicwq panicwq changed the title 3.0.5.1社区版本,c++连接,平均值查询总是0 c++连接,聚合函数查询总是0 Nov 22, 2024
@panicwq panicwq changed the title c++连接,聚合函数查询总是0 c++连接,聚合函数(avg,sum)查询得到结果为0或接近0的值 Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant