--学生表
create table t_student
(
id number,
name varchar2(100),
sex number
)
;
-- Add comments to the columns
comment on column t_student.id
is 'id';
comment on column t_student.name
is '姓名';
comment on column t_student.sex
is '性别0:男 1:女';
--查询男、女生的数量
--count(1),算在总数内。
--count(null),不算在总数内。
select count(decode(sex, 0, 1, null)) boyNum,
count(decode(sex, 1, 1, null)) girlNum
from t_student
Oracle-count加条件计算
最新推荐文章于 2024-02-18 14:18:06 发布