1

I have a table with 3 columns: key, status and rank.
status contains numbers and rank contains t or f.
key is auto numbered and irrelevant here.

my goal is to count how many in each status are t and how many false for example:

if my data is (key, status, rank)

1 10 f
2 10 t
3 10 t
4 11 t

then result will be : (status, rank, count value)

10 f 1
10 t 2
11 t 1

how do i do that?

1 Answer 1

1

This is a simple group by query.

select status, 
       rank,
       count(*) as cnt
from the_table
group by status, rank
order by status, rank;
3
  • where do you take under consideration the rank? it seems like you just counting statuses regardless of the rank. Commented Jun 1, 2015 at 8:38
  • ok based on your answer this is the correct solution: select status, rank, count(*) as cnt from the_table group by status, rank order by status; Commented Jun 1, 2015 at 8:41
  • @someone45: ah, sorry. I mixed up the columns. Commented Jun 1, 2015 at 8:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.