|
楼主 |
发表于 2019-11-18 14:11:09
|
显示全部楼层
本帖最后由 Len 于 2019-11-18 14:12 编辑
现 person 表 共 3728 行记录,1449 启用,2279 禁用
org 表 共 6590 行记录,2662 启用,3928 禁用
请问是哪里出现问题,应该是怎样统计到 1502 ? 真正统计 的 sql 应该是怎样
SELECT 'person' as "table",COUNT(1) AS "total",
SUM(DECODE(P.SVALIDSTATE,1,1,0)) AS "1",
SUM(DECODE(P.SVALIDSTATE,-1,1,0)) AS "-1" ,
SUM(DECODE(P.SVALIDSTATE,0,1,0)) AS "0"
FROM SA_OPPERSON P
UNION ALL
SELECT 'org' as "table",COUNT(1) AS "total",
SUM(DECODE(ORG.SVALIDSTATE,1,1,0)) AS "1",
SUM(DECODE(ORG.SVALIDSTATE,-1,1,0)) AS "-1" ,
SUM(DECODE(org.SVALIDSTATE,0,1,0)) AS "0"
FROM SA_OPORG ORG WHERE ORG.SORGKINDID IN ('psm')
;
|
|