SELECT SUM(CASE WHEN STATE=1 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=2 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=3 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=4 THEN 1 ELSE 0 END) FROM TB
SELECT SUM(CASE WHEN STATE=1 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=2 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=3 THEN 1 ELSE 0 END) ,SUM(CASE WHEN STATE=4 THEN 1 ELSE 0 END) FROM TB