SELECT NAME,
	openid,
	userid,
	sum( notexectasknum ) notexectasknum,
	sum( outtimetasknum ) outtimetasknum 
FROM
	(
	SELECT USER
		.realname NAME,
		suser.openid,
		suser.id userid,
	CASE
			taskstatus 
			WHEN '0' THEN
			1 
			WHEN '1' THEN
			1 ELSE 0 
		END notexectasknum,
	0 outtimetasknum 
FROM
	p_projecttask task
	LEFT JOIN t_s_base_user USER ON USER.id = task.
	OWNER LEFT JOIN t_s_user suser ON task.OWNER = suser.id 
WHERE
	1 = 1 
	AND LEFT ( task.planendtime, 10 ) >= :today AND LEFT(task.msgtime ,10) <= :today
UNION ALL
SELECT USER
	.realname NAME,
	suser.openid,	
	suser.id userid,
	0 notexectasknum,
CASE
		
		WHEN LEFT ( planendtime, 10 ) < :today
		AND ( taskstatus = '0' OR taskstatus = '1' ) THEN
			1 ELSE 0 
		END outtimetasknum 
FROM
	p_projecttask task
	LEFT JOIN t_s_base_user USER ON USER.id = task.
	OWNER LEFT JOIN t_s_user suser ON task.OWNER = suser.id 
WHERE
	1 = 1 
	AND LEFT ( task.planendtime, 10 ) < :today
	) temp 
GROUP BY
	openid,userid