SELECTorg2.nameAS列Q,pro.ProNameAS列X,(SELECTCOUNT(*)from表AASAI1whereAI1.ProjectID=pr.pridandUpdateTime>DATE_SUB(NOW(),INTERVAL5DAY)ANDStatus='2'andStatus='3')ASDATE1,表...
SELECT org2.name AS 列Q,pro.ProName AS 列X,
(SELECT COUNT(*) from 表A AS AI1
where AI1.ProjectID=pr.prid and UpdateTime > DATE_SUB(NOW(),INTERVAL 5 DAY) AND Status ='2' and Status ='3') AS DATE1,
表A
(SELECT COUNT(*) from 表A AS AI2
where AI2.ProjectID=pr.prid and UpdateTime > DATE_ADD(ConfirmTime,INTERVAL 5 DAY) AND Status !='2' and Status !='3' and Status !='255') AS DATE2,
from 表project AS pro
LEFT JOIN or_org AS org ON org.id=pro.orgid
LEFT JOIN or_org AS org2 ON org2.id=org.pa
WHERE pro.isdeleted=0
and pro.State=1
create table test (id int);
insert into test values(1),(2),(3),(4),(5),(6),(7),(8);
例如:查询id大于4和id=1的统计
一般写法
select count(case when id>4 then id end),count(case when id=1 then id end ) from test;
非主流写法:
select count(id>4 or null),count(id=1 or null) from test;
--------------------------------------------------------------------
以上测试通过