Marr Camino
Marr Camino

Reputation: 3

SELECT COUNT with HAVING NOT IN - SQL Syntax

I just want to count how many student users are online, but not included the account type "Admin" and "Professor", and this is my syntax that has an error

SELECT  COUNT(`status`) 
FROM `tbl_registration` 
WHERE `status` = 'Online' 
NOT HAVING accounttype IN ('Admin','Professor') 

Upvotes: 0

Views: 29

Answers (1)

Thallius
Thallius

Reputation: 2619

You do not need having (which mostly slows down performance)

SELECT COUNT(status) FROM tbl_registration WHERE status = 'Online' AND accounttype NOT IN ('Admin','Professor')

Upvotes: 1

Related Questions