简体   繁体   中英

Show Records with Zero Count Using Where Statement

The following statement queries a table, which lists a list of employees who have taken an "AS" training session. Some employees have taken the "AS" training several times and may show up on the list multiple times.

SELECT schedule_test.ID, (COUNT(CASE WHEN schedule_test.Course LIKE 'AS%' 
THEN schedule_test.Course END)) AS "AS" 
FROM schedule_test
GROUP BY schedule_test.ID

在此处输入图片说明

I would like to now add a WHERE statement to only show the employees who have not taken an "AS" session, or to put it another way show employees that only have 0 "AS" sessions. I have tried:

WHERE "AS"==0 with no success. 
I even tried WHERE "AS" < 1 with no success.

Could use some help.

Try:

HAVING count(course) < 1

At the end of your query

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM