Hi, I have two tables #users and #activity:
I would like to update #users.printcount to reflect the number of times each user printed in #activity.description.
I tried the following to get my results:
But the results only shows;
Alex, 3
bob, 3
I would like the results to show a 0 count for jim:
alex, 3
bob, 3
jim, 0
Any idea how I can change my script to reflect this?
SQL 2000
Thanks,
Brian
Code:
create table #users (name varchar(25), printcount int)
go
insert into #users (name) values ('bob')
insert into #users (name) values ('jim')
insert into #users (name) values ('alex')
create table #activity (name varchar(25), description varchar(25))
go
insert into #activity values ('bob', 'printed')
insert into #activity values ('bob', 'printed')
insert into #activity values ('bob', 'printed')
insert into #activity values ('bob', 'searched')
insert into #activity values ('alex', 'printed')
insert into #activity values ('alex', 'printed')
insert into #activity values ('alex', 'searched')
insert into #activity values ('alex', 'searched')
insert into #activity values ('alex', 'printed')
I would like to update #users.printcount to reflect the number of times each user printed in #activity.description.
I tried the following to get my results:
Code:
select #users.name, count (#activity.description)
from #users
left outer join #activity
on #activity.name = #users.name
where description = 'printed'
group by #users.name
But the results only shows;
Alex, 3
bob, 3
I would like the results to show a 0 count for jim:
alex, 3
bob, 3
jim, 0
Any idea how I can change my script to reflect this?
SQL 2000
Thanks,
Brian