我正在尝试计算配置单元中视图的记录计数的平均/最小/最大值
select avg(rec_count), max(rec_count), min(rec_count)
并试图实现以下目标:
select avg(rec_count), max(rec_count), min(rec_count)
where rec_count in
(select count(record_number) as rec_count from archives
group by record_number);
但我收到一条错误信息:
失败:semanticexception行0:-1子查询sq\u 1的定义中的列引用“rec\u count”无效[rec\u count in(select count(record\u number)as rec\u count from archives group by record\u number)]在第2:18行用作sq\u 1
我想知道我是否可以这样做,而不必创建另一个包含原始表的分组/聚合值的表/视图。
样本数据:
记录编号3031有4条记录,4050有6条记录,因此我希望从查询中得到的预期结果是:
平均值=5最小值=4最大值=6
1条答案
按热度按时间8xiog9wr1#
我想你想要的是: