select WorkerID,SUM(CASE WHEN WorkType='°´Ê±Ï°à' THEN 1 ELSE 0 END) AS a from CheckWorker where WorkerID=17 GROUP BY WorkerID
Õâ¸öÓï¾äÔÚaccessÖÐÌáʾ"Óï·¨´íÎó(²Ù×÷·û¶ªÊ§)ÔÚ²éѯ±í´ïʽ'SUM(CASE WHEN WorkType='°´Ê±Ï°à' THEN 1 ELSE 0 END)'ÖÐ ÔÚsql2000²éѯ·ÖÎöÆ÷ÖвâÊÔÊÇͨ¹ýµÄ ºÜ¼±Ñ½,лл!
ÊÔÊÔ SQL code:
select WorkerID,SUM(CASE [WorkType] WHEN '°´Ê±Ï°à' THEN 1 ELSE 0 END) AS a from CheckWorker where WorkerID=17 GROUP BY WorkerID
»¹ÓÐÄãµÄACCESSÖ§³Ö case Óï¾äÂð?
Ôõô֪µÀaccessÖ§³Ö²»Ö§³ÖcaseÓï¾ä? ÄãµÄÓï¾äÎÒÊÔ¹ýÁË£¬»¹ÊÇÒ»ÑùµÄ´íÎó ¹À¼ÆÊÇÒòΪaeecss²»Ö§³ÖcaseÓï¾ä,ÄÜÓÃʲô´úÌæcaseÓï¾ä,ʵÏÖÎÒÒªµÄ½á¹ûÂð? CASE WHEN WorkType='°´Ê±Ï°à' THEN 1 ELSE 0 END --------------> iif(WorkType='°´Ê±Ï°à',1,0)