【IT168 服务器学院】Multiple在表中的计算
create table myTable (
this Varchar2(10),
that Varchar2(10)
);
insert into myTable values (''that'' , ''the other'');
insert into myTable values (''confusing'', ''the other'');
insert into myTable values (''this'' , ''that'' );
insert into myTable values (''this'' , ''that'' );
insert into myTable values (''that'' , ''confusing'');
insert into myTable values (''confusing'', ''that'' );
insert into myTable values (''confusing'', ''confusing'');
insert into myTable values (''that'' , ''the other'');
insert into myTable values (''this'' , ''that'' );
insert into myTable values (''confusing'', ''the other'');
select
count(
case when
this = ''that'' and
that = ''the other''
then 1
else null end) "Count 1",
count(
case when
this = ''this'' and
that = ''that''
then 1
else null end) "Count 2",
count(
case when
this = ''confusing''
then 1
else null end) "Count 3"
from
myTable;