建表,测试数据:
create table test
(收款标志 int)
insert into test values (1);
insert into test values (1);
insert into test values (1);
commit;
执行:
select case
when a.cnt = b.cnt then
'未收款'
when a.cnt = d.cnt then
'已收款'
when c.cnt <> 0 then
'部分收款'
end 收款状态
from (select count(*) cnt from test) a,
(select count(*) cnt from test where 收款标志 = 1) b,
(select count(*) cnt from test where 收款标志 = 2) c,
(select count(*) cnt from test where 收款标志 = 3) d
结果:
然后你自己换点其他数据测试一下吧,思路就这么个思路了。