1
create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
2
insert into t1 values (1, 3);
3
select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
4
count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ
6
select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
7
Case When Count(*) < MAX_REQ Then 1 Else 0 End
10
create table t1m (a int) engine=myisam;
11
create table t1i (a int) engine=innodb;
12
create table t2m (a int) engine=myisam;
13
create table t2i (a int) engine=innodb;
14
insert into t2m values (5);
15
insert into t2i values (5);
16
select min(a) from t1m;
19
select min(7) from t1m;
25
explain select min(7) from t2m join t1m;
26
id select_type table type possible_keys key key_len ref rows Extra
27
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
28
select min(7) from t2m join t1m;
31
select max(a) from t1m;
34
select max(7) from t1m;
40
explain select max(7) from t2m join t1m;
41
id select_type table type possible_keys key key_len ref rows Extra
42
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
43
select max(7) from t2m join t1m;
46
select 1, min(a) from t1m where a=99;
49
select 1, min(a) from t1m where 1=99;
52
select 1, min(1) from t1m where a=99;
55
select 1, min(1) from t1m where 1=99;
58
select 1, max(a) from t1m where a=99;
61
select 1, max(a) from t1m where 1=99;
64
select 1, max(1) from t1m where a=99;
67
select 1, max(1) from t1m where 1=99;
70
select min(a) from t1i;
73
select min(7) from t1i;
79
explain select min(7) from t2i join t1i;
80
id select_type table type possible_keys key key_len ref rows Extra
81
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
82
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
83
select min(7) from t2i join t1i;
86
select max(a) from t1i;
89
select max(7) from t1i;
95
explain select max(7) from t2i join t1i;
96
id select_type table type possible_keys key key_len ref rows Extra
97
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
98
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
99
select max(7) from t2i join t1i;
102
select 1, min(a) from t1i where a=99;
105
select 1, min(a) from t1i where 1=99;
108
select 1, min(1) from t1i where a=99;
111
select 1, min(1) from t1i where 1=99;
114
select 1, max(a) from t1i where a=99;
117
select 1, max(a) from t1i where 1=99;
120
select 1, max(1) from t1i where a=99;
123
select 1, max(1) from t1i where 1=99;
126
explain select count(*), min(7), max(7) from t1m, t1i;
127
id select_type table type possible_keys key key_len ref rows Extra
128
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
129
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
130
select count(*), min(7), max(7) from t1m, t1i;
131
count(*) min(7) max(7)
133
explain select count(*), min(7), max(7) from t1m, t2i;
134
id select_type table type possible_keys key key_len ref rows Extra
135
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
136
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
137
select count(*), min(7), max(7) from t1m, t2i;
138
count(*) min(7) max(7)
140
explain select count(*), min(7), max(7) from t2m, t1i;
141
id select_type table type possible_keys key key_len ref rows Extra
142
1 SIMPLE t2m system NULL NULL NULL NULL 1
143
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
144
select count(*), min(7), max(7) from t2m, t1i;
145
count(*) min(7) max(7)
147
drop table t1m, t1i, t2m, t2i;