table Devices:
id device type_id device_status
1 dev1 2 1
2 dev2 2 2
3 dev3 7 2
4 dev5 9 3
models table:
model_id vendor_id model_name
1 3 name1
2 5 name2
3 7 name3
4 7 name4
and query looks this:
SELECT model_id, type_id, model_name,
COUNT(type_id) AS numOfDevices
FROM devices
LEFT JOIN models ON models.model_id = devices.type_id
WHERE device_status = 2 OR device_status = 3
GROUP BY type_id
what I am getting from that query is:
There are $numOfDevices $model_name items.
and this is OK, but is there a way to count devices only with device_status =3 in the same query?