Reputation: 19
Need some help to count the amount of "job_id" for my specifik "customer_id"
The tabel is looking like this:
Customer_id | Job_id |
---|---|
1 | 101 |
1 | 102 |
2 | 103 |
1 | 104 |
1 | 105 |
2 | 106 |
2 | 107 |
I would like to make a query like this, to get the job_id in order (a count) for the specifik Customer_id:
Customer_id | Job_id_count |
---|---|
1 | 4 |
2 | 3 |
Upvotes: 0
Views: 70
Reputation: 1075
It seems you need group by
and count
aggregate function as follows:
select customer_id, count(job_id)
from your_table
group by customer_id;
If table contains duplicate customer_id-job_id
mapping and you want to consider it as a one count only then you can also use distinct
inside count
as follows:
select customer_id, count(distinct job_id)
from your_table
group by customer_id;
Upvotes: 0