Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Filling a datatable column with null

Author  Topic 

enak
Starting Member

34 Posts

Posted - 2006-04-25 : 14:19:58
I am using vb.net to gather some data from an MS SQL 2000 database. I create a datatable and populate it with a list of sales people in the first column.

Next, I want to be able to retrieve the sales totals for each person for the given day. So, for my example here, there are 20 rows and there are enough columns to list the totals for each day of the month up to today.

The case is coming up where not everyone is selling on each day so when I retrieve the sales total for a certain day I may only get the totals for 18 of the sales people. Here is my sql:

select interviewer, CASE WHEN count(*) IS NULL THEN 0 ELSE count(*) END As Interviews from interview
Where int_date = '4/20/2006'
Group By Interviewer
order by interviews Desc

Here is what I want to see:

interviewer Interviews
A 10
B 11
C 9
D 3
E 17
F 0
G 0
H 2
I 12
J 0
K 9
L 4
M 5
N 3
O 1
P 0
Q 8
R 4
S 5
T 0

If one of the sales people do not have any totals for the given day I want to show a zero.

How can I do this?

Thanks,
enak

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-25 : 14:34:09
try

isnull((count(*)),0 )


Srinika
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-25 : 18:19:37
do you have a table contains all the interviewer ?
use it to left join to this table



KH


Go to Top of Page
   

- Advertisement -