user7461846
user7461846

Reputation:

count items inside each of distinct status

Table abc - suppose there are three columns: id, title and status

select distinct status from abc; 

Result:

home
archive
wait
aauth
impress

select count(distinct status) from abc;  

Result: 5

What I need is to count items inside each distinct status:

home       10
archive    14
wait       17
aauth      19
impress    27

Any help?

Upvotes: 0

Views: 23

Answers (1)

Ethan
Ethan

Reputation: 4375

Try using GROUP BY:

SELECT status, COUNT(*) FROM abc GROUP BY status;

Upvotes: 3

Related Questions