RE: problem with distinct...

RE: problem with distinct...

 

  

This doesn't give you what you need?

Select cast(count(DISTINCT userid) as varchar(10))
from <table>
where userid like 'ntlocal%'

-Greg

-----Original Message-----
From: Ellingson Cory (RCIS)
[mailto:mssqldba-ezmlmshield-x70756512.[Email address protected]
Sent: Wednesday, November 24, 2004 11:27 AM
To: LazyDBA Discussion
Subject: problem with distinct...


Hello -

I have some data that I need to count for upper management...

Sample data:
USERID
ntlocal://COM0004775/SYSTEM
ntlocal://COM0004073/SYSTEM
ntlocal://COM0004775/SYSTEM
ntlocal://COM0004775/SYSTEM
ntlocal://COM0004377/SYSTEM
ntlocal://COM0004073VM1/SYSTEM

now, I need a count of each machine (ntlocal://com#####/system), but there
the duplicates are screwing my results...I have tried distinct, but that
does not help...

Select cast(count(userid) as varchar(10))
from <table>
where userid like 'ntlocal%'

any help would be appreciated!

Cory


---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: mssqldba-[Email address protected]


MS Sql Server LazyDBA home page