Question : SQL 2000 - Getting COUNT, not SUM

Please note that this is SQL 2000

I want to see how many callers have called more than once. I dont want to get the SUM. For example, if I have a phone number twice..i know this person has called twice..so it counts as one. If somone has called in 10 times, that i know this person has also called in more than once...etc

I have the SQL below. For this caller  originatorDN  =  '11111'...i have 2 rows for '11111'. So, this person has called twice ..so this phone number should be counted as one...

This is what I have:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
declare @startdate as datetime
declare @enddate as datetime

set @startdate = '2010-07-29'
set @enddate = '2010-07-29'

select case max(ccdr.callednumber) when '5900' then 'NX' else 'NX' end as company 
            --,max(ccdr.originatorDN) -- see below, tried SUM and COUNT
            ,isnull(sum (case when ccdr.originatorDN <> '' then 1 else 0 end),0) -- tried this
        
 from db_cra.dbo.ContactCallDetail ccdr 
      inner JOIN ContactQueueDetail cqd ON cqd.sessionID = ccdr.sessionid 
  WHERE  ccdr.startDateTime >= DATEADD(dd, 0, DATEDIFF(dd, 0, @startdate)) 
         AND ccdr.startDateTime < DATEADD(dd, 0, DATEDIFF(dd, 0, @enddate +1)) 
         AND  applicationName = 'Main' 
         AND  ccdr.callednumber IN ('5900')  and originatorDN  =  '11111'
 group by ccdr.originatorDN
  having count(ccdr.originatorDn) > 1

I get

NX    2

I should get
NX    1

Answer : SQL 2000 - Getting COUNT, not SUM

Hope this is what you require:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
declare @startdate as datetime
declare @enddate as datetime

set @startdate = '2010-07-29'
set @enddate = '2010-07-29'

select case max(ccdr.callednumber) when '5900' then 'NX' else 'NX' end as company 
            , 1 cnt -- tried this
        
 from db_cra.dbo.ContactCallDetail ccdr 
      inner JOIN ContactQueueDetail cqd ON cqd.sessionID = ccdr.sessionid 
  WHERE  ccdr.startDateTime >= DATEADD(dd, 0, DATEDIFF(dd, 0, @startdate)) 
         AND ccdr.startDateTime < DATEADD(dd, 0, DATEDIFF(dd, 0, @enddate +1)) 
         AND  applicationName = 'Main' 
         AND  ccdr.callednumber IN ('5900')  and originatorDN  =  '11111'
 group by ccdr.originatorDN
  having count(ccdr.originatorDn) > 1
Random Solutions  
 
programming4us programming4us