SELECT
COUNT(status='HOLD') as COUNThold,
COUNT(status='SITE') as COUNTsite,
COUNT(status='FACTORY') as COUNTfactory,
COUNT(MONTH(ACTIVITY_DATE)='02') as COUNTstatus,
FROM activity
ไม่ได้ทดสอบ ขอโทษอีกที่ เปลี่ยน count เป็น sum ครับ ชักเบลอครับ
ทดสอบ แล้ว Code (SQL)
SELECT
SUM( status='HOLD') as COUNThold,
SUM( status='SITE') as COUNTsite,
SUM( status='FACTORY') as COUNTfactory,
SUM(MONTH(ACTIVITY_DATE)='02') as COUNTstatus
FROM (
SELECT 'HOLD' status, '2015-02-28' ACTIVITY_DATE UNION ALL
SELECT 'FACTORY', '2015-02-28' UNION ALL
SELECT 'SITE', '2015-02-28' UNION ALL
SELECT 'HOLD', '2015-02-28' UNION ALL
SELECT 'SITE', '2015-02-28' UNION ALL
SELECT 'HOLD', '2015-02-28' UNION ALL
SELECT 'HOLD', '2015-02-28' UNION ALL
SELECT 'SITE', '2015-02-28' UNION ALL
SELECT 'HOLD', '2015-02-28' UNION ALL
SELECT 'FACTORY', '2015-02-28' UNION ALL
SELECT 'HOLD', '2015-02-28'
) AS TEMP
SELECT
SUM( status='HOLD') as COUNThold,
SUM( status='SITE') as COUNTsite,
SUM( status='FACTORY') as COUNTfactory,
SUM(MONTH(ACTIVITY_DATE)='02') as COUNTstatus
FROM tablename