Hi,
I have a table:
uid task_id yr
------------------------
1 101 08
2 101 09
3 102 08
4 102 09
5 102 10
I need to determine 2 things:
1) distinct list of yr's
2) count of task_id's for a particular yr
So, in my simplified example the results would look like:
yr task_id_count
-------------------------
08 2
09 2
10 1
I've tried using a self-join w/ no luck:
select distinct t1.yr as yr,
(select count(distinct task_id)
from mytable
where t1.task_id = t2.task_id) as task_id_count
from mytable t1 inner join
mytable t2
on t1.task_id = t2.task_id
order by t1.yr
Any help would be greatly appreciated!
-mD.
I have a table:
uid task_id yr
------------------------
1 101 08
2 101 09
3 102 08
4 102 09
5 102 10
I need to determine 2 things:
1) distinct list of yr's
2) count of task_id's for a particular yr
So, in my simplified example the results would look like:
yr task_id_count
-------------------------
08 2
09 2
10 1
I've tried using a self-join w/ no luck:
select distinct t1.yr as yr,
(select count(distinct task_id)
from mytable
where t1.task_id = t2.task_id) as task_id_count
from mytable t1 inner join
mytable t2
on t1.task_id = t2.task_id
order by t1.yr
Any help would be greatly appreciated!
-mD.