| ceoModel_id | Qt_ceoModel |
|:----------- |------------:|
| 2 | 1 |
| 3 | 2 |
| 4 | 2 |
CodePudding user response:
select ceoModel_id,
count(ceoModel_id) as Qt_ceoModel
from inventory_ceos
group by ceoModel_id;
This works?
CodePudding user response:
You nbeed to GROUP BY ceoModel_id
CREATE tABLE inventory_ceos (ceoModel_id int)
INSERT INTO inventory_ceos VALUES(1),(2),(2),(3),(3)
SELECT ceoModel_id, COUNT(*) AS Qt_ceoModel FROM inventory_ceos GROUP BY ceoModel_id
ceoModel_id | Qt_ceoModel ----------: | ----------: 1 | 1 2 | 2 3 | 2
db<>fiddle here