← Back
Editing: count_distinct2.result
drop table if exists t1; SET @big_tables_save=@@big_tables; create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text); insert into t1 values (1,11, 'one','eleven', 'eleven'), (1,11, 'one','eleven', 'eleven'), (2,11, 'two','eleven', 'eleven'), (2,12, 'two','twevle', 'twelve'), (2,13, 'two','thirteen', 'foo'), (2,13, 'two','thirteen', 'foo'), (2,13, 'two','thirteen', 'bar'), (NULL,13, 'two','thirteen', 'bar'), (2,NULL, 'two','thirteen', 'bar'), (2,13, NULL,'thirteen', 'bar'), (2,13, 'two',NULL, 'bar'), (2,13, 'two','thirteen', NULL); select distinct n1 from t1; n1 1 2 NULL select count(distinct n1) from t1; count(distinct n1) 2 select distinct n2 from t1; n2 11 12 13 NULL select count(distinct n2) from t1; count(distinct n2) 3 select distinct s from t1; s NULL one two select count(distinct s) from t1; count(distinct s) 2 select distinct vs from t1; vs NULL eleven thirteen twevle select count(distinct vs) from t1; count(distinct vs) 3 select distinct t from t1; t NULL bar eleven foo twelve select count(distinct t) from t1; count(distinct t) 4 select distinct n1,n2 from t1; n1 n2 1 11 2 11 2 12 2 13 2 NULL NULL 13 select count(distinct n1,n2) from t1; count(distinct n1,n2) 4 select distinct n1,s from t1; n1 s 1 one 2 NULL 2 two NULL two select count(distinct n1,s) from t1; count(distinct n1,s) 2 select distinct s,n1,vs from t1; s n1 vs NULL 2 thirteen one 1 eleven two 2 NULL two 2 eleven two 2 thirteen two 2 twevle two NULL thirteen select count(distinct s,n1,vs) from t1; count(distinct s,n1,vs) 4 select distinct s,t from t1; s t NULL bar one eleven two NULL two bar two eleven two foo two twelve select count(distinct s,t) from t1; count(distinct s,t) 5 select count(distinct n1), count(distinct n2) from t1; count(distinct n1) count(distinct n2) 2 3 select count(distinct n2), n1 from t1 group by n1; count(distinct n2) n1 1 NULL 1 1 3 2 drop table t1; create table t1 (n int default NULL); flush status; select count(distinct n) from t1; count(distinct n) 5000 show status like 'Created_tmp_disk_tables'; Variable_name Value Created_tmp_disk_tables 0 drop table t1; SET SESSION big_tables=1; create table t1 (s text); flush status; select count(distinct s) from t1; count(distinct s) 5000 show status like 'Created_tmp_disk_tables'; Variable_name Value Created_tmp_disk_tables 1 drop table t1; SET SESSION big_tables=@big_tables_save;
Save File
Cancel