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)
 Count the Distinct with conditonal select

Author  Topic 

andrewcw
Posting Yak Master

133 Posts

Posted - 2005-05-15 : 00:20:45
can this be done, but I keep getting syntax errors.

I need to count the # of rows returned from this:
SELECT DISTINCT Customer
FROM dbo.TestBlockStatus
WHERE (ModelEnum = 0) AND (SystemName = '2731')

But this does not work, why ?? & how to fix it ( Thanks ! )

SELECT COUNT(*) AS inTotal
FROM dbo.TestBlockStatus
(WHERE SELECT DISTINCT Customer
FROM dbo.TestBlockStatus
WHERE (ModelEnum = 0) AND (SystemName = '2731')) as A

andrewcw

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2005-05-15 : 06:33:21
[code]
SELECT count(DISTINCT Customer) as inTotal
FROM dbo.TestBlockStatus
WHERE (ModelEnum = 0) AND (SystemName = '2731')
[/code]
Go to Top of Page

andrewcw
Posting Yak Master

133 Posts

Posted - 2005-05-15 : 12:39:23
Thanks very MUCH ! It works !

andrewcw
Go to Top of Page
   

- Advertisement -