1 代碼
1.1 當當前字段為空,查詢結果返回“none”,並且統計出現頻率
1
|
select
case
when
字段
is
null
then
'none'
else
字段
end
as
字段,
count
(1)
as
counts
from
表
group
by
字段;
|
1.2 當當前字段為空字符串,查詢結果返回“none”,並且統計出現頻率
1
|
select
case
when
字段=
''
then
'none'
else
字段
end
as
字段,
count
(1)
as
counts
from
表
group
by
字段;
|
1.3 當當前字段為空,查詢結果返回“none”
1
|
select
case
when
字段
is
null
then
'none'
else
字段
end
as
字段
from
表;
|
1.4 當當前字段為空字符,查詢結果返回“none”
1
|
select
case
when
字段=
''
then
'none'
else
字段
end
as
字段
from
表;
|
2 小結
僅作為記錄使用,mysql其它相關命令有isnull,ifnull and nullif。