📄 count_distinct2.result
字号:
drop table if exists t1;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;n112NULLselect count(distinct n1) from t1;count(distinct n1)2select distinct n2 from t1;n2111213NULLselect count(distinct n2) from t1;count(distinct n2)3select distinct s from t1;sonetwoNULLselect count(distinct s) from t1;count(distinct s)2select distinct vs from t1;vseleventwevlethirteenNULLselect count(distinct vs) from t1;count(distinct vs)3select distinct t from t1;televentwelvefoobarNULLselect count(distinct t) from t1;count(distinct t)4select distinct n1,n2 from t1;n1 n21 112 112 122 13NULL 132 NULLselect count(distinct n1,n2) from t1;count(distinct n1,n2)4select distinct n1,s from t1;n1 s1 one2 twoNULL two2 NULLselect count(distinct n1,s) from t1;count(distinct n1,s)2select distinct s,n1,vs from t1;s n1 vsone 1 eleventwo 2 eleventwo 2 twevletwo 2 thirteentwo NULL thirteenNULL 2 thirteentwo 2 NULLselect count(distinct s,n1,vs) from t1;count(distinct s,n1,vs)4select distinct s,t from t1;s tone eleventwo eleventwo twelvetwo footwo barNULL bartwo NULLselect count(distinct s,t) from t1;count(distinct s,t)5select count(distinct n1), count(distinct n2) from t1;count(distinct n1) count(distinct n2)2 3select count(distinct n2), n1 from t1 group by n1;count(distinct n2) n11 NULL1 13 2drop table t1;create table t1 (n int default NULL);flush status;select count(distinct n) from t1;count(distinct n)5000show status like 'Created_tmp_disk_tables';Variable_name ValueCreated_tmp_disk_tables 0drop table t1;create table t1 (s text);flush status;select count(distinct s) from t1;count(distinct s)5000show status like 'Created_tmp_disk_tables';Variable_name ValueCreated_tmp_disk_tables 1drop table t1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -