注册

聚合函数Max会返回NULL

悟道 2024/11/14 630 4

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: DM 64 V8 03134284294-20241009-244896-20119
【操作系统】:windows
【CPU】:8
【问题描述】*:聚合函数Max在索引字段过滤后记录结果集为1的场景下的max的结果为空,具体键详细内容
验证SQL:
drop table if exists tbtest;
create table tbtest (
col1 int default 1 not null,
col2 int default 1 not null,
constraint PK_TEST primary key (col1)
);
insert into tbtest values(1000,1000);
(1)测试1:通过索引过滤且对索引字段求max,结果错误
select min(col1), max(col1) from tbtest where col1 >=1000 and col1 <2000;
image.png
(2)测试2:通过索引字段过滤对非索引字段求max,结果正确
select min(col2), max(col2) from tbtest where col1 >=1000 and col1 <2000;
image.png
(3)测试3:通过非索引字段过滤,对索引字段求max,结果正确
select min(col1), max(col1) from tbtest where col2 >=1000 and col2 <2000;
image.png

回答 0
暂无回答
扫一扫
联系客服