github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_aggr_min.test (about) 1 #NULL 2 SELECT min(null); 3 4 #DATATYPE 5 create table t1(a tinyint, b SMALLINT, c bigint, d INT, e BIGINT, f FLOAT, g DOUBLE, h decimal(38,19), i DATE, k datetime, l TIMESTAMP, m char(255), n varchar(255)); 6 insert into t1 values(1, 1, 2, 43, 5, 35.5, 31.133, 14.314, "2012-03-10", "2012-03-12 10:03:12", "2022-03-12 13:03:12", "ab23c", "d5cf"); 7 insert into t1 values(71, 1, 2, 34, 5, 5.5, 341.13, 15.314, "2012-03-22", "2013-03-12 10:03:12", "2032-03-12 13:04:12", "abr23c", "3dcf"); 8 insert into t1 values(1, 1, 21, 4, 54, 53.5, 431.13, 14.394, "2011-03-12", "2015-03-12 10:03:12", "2002-03-12 13:03:12", "afbc", "dct5f"); 9 insert into t1 values(1, 71, 2, 34, 5, 5.5, 31.313, 124.314, "2012-01-12", "2019-03-12 10:03:12", "2013-03-12 13:03:12", "3abd1c", "dcvf"); 10 select min(a) from t1; 11 select min(b) from t1; 12 select min(c) from t1; 13 select min(d) from t1; 14 select min(e) from t1; 15 select min(f) from t1; 16 select min(g) from t1; 17 select min(h) from t1; 18 select min(i) from t1; 19 select min(k) from t1; 20 select min(l) from t1; 21 select min(m) from t1; 22 select min(n) from t1; 23 drop table t1; 24 25 #0.5暂不支持time类型 26 #create table t1(a time) 27 #insert into t1 values("10:03:12"); 28 #insert into t1 values("10:03:12"); 29 #insert into t1 values("10:03:12"); 30 #insert into t1 values("10:03:12"); 31 #select min(a) from t1; 32 #drop table t1; 33 34 35 #EXTREME VALUE, 算术操作 36 select min(99999999999999999.99999); 37 select min(999999999999999933193939.99999); 38 select min(9999999999999999999999999999999999.9999999999999); 39 select min(-99999999999999999.99999); 40 select min(-999999999999999933193939.99999); 41 select min(-9999999999999999999999999999999999.9999999999999); 42 43 -- @bvt:issue#3344 44 create table t1(a bigint); 45 select min(a) from t1; 46 insert into t1 values(null),(null),(null),(null); 47 select min(a) from t1; 48 insert into t1 values(12417249128419),(124124125124151),(5124125151415),(124125152651515); 49 select min(a) from t1; 50 drop table t1; 51 -- @bvt:issue 52 53 create table t1 ( a int not null default 1, big bigint ); 54 insert into t1 (big) values (-1),(1234567890167),(92233720368547),(18446744073709515); 55 select * from t1; 56 select min(big),max(big),min(big)-1 from t1; 57 select min(big),max(big),min(big)-1 from t1 group by a; 58 insert into t1 (big) values (184467440737615); 59 select * from t1; 60 select min(big),max(big),min(big)-1 from t1; 61 select min(big),max(big),min(big)-1 from t1 group by a; 62 drop table t1; 63 64 65 #HAVING, DISTINCT#HAVING,DISTINCT 66 CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL); 67 INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50); 68 #select Fld1, min(distinct Fld2) as q from t1 group by Fld1 having q is not null; 69 select Fld1, min( Fld2) as q from t1 group by Fld1 having q is not null; 70 select Fld1, min(Fld2) from t1 group by Fld1 having min(Fld2) is not null; 71 select Fld1, min(Fld2) from t1 group by Fld1 having avg(Fld2) is not null; 72 select Fld1, min(Fld2) from t1 group by Fld1 having std(Fld2) is not null; 73 select Fld1, min(Fld2) from t1 group by Fld1 having variance(Fld2) is not null; 74 drop table t1; 75 76 #比较操作 77 SELECT min(1)<min(2); 78 79 create table t1 (grp int, a bigint unsigned, c char(10) not null); 80 insert into t1 values (1,1,"a"); 81 insert into t1 values (2,2,"b"); 82 insert into t1 values (2,3,"c"); 83 insert into t1 values (3,4,"E"); 84 insert into t1 values (3,5,"C"); 85 insert into t1 values (3,6,"D"); 86 select min(distinct a),min(distinct grp) from t1; 87 insert into t1 values (null,null,''); 88 select min(distinct a),min(distinct grp) from t1; 89 drop table t1; 90 91 CREATE TABLE t1 (a INT); 92 INSERT INTO t1 SELECT result FROM generate_series(1,100000) g; 93 SELECT MIN(a) FROM t1; 94 DELETE FROM t1 WHERE a<=50000; 95 SELECT MIN(a) FROM t1; 96 DELETE FROM t1 WHERE a%2=1; 97 SELECT MIN(a) FROM t1; 98 DROP TABLE t1;