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
 Old Forums
 CLOSED - General SQL Server
 Count

Author  Topic 

ChetShah
Starting Member

37 Posts

Posted - 2005-10-06 : 07:15:58
Hi,

I'm not sure how to get this to work , i have a query that returns the following results:

ClaimRef
-----------
ADKIN00010
ADKIN00012
ADKIN00014
ADKIN00015
ADKIN00016
ADKIN00017
ADKIN00018
ADKIN00019
ADKIN00020

I want a write a count query which will return count of ADKIN = 9 ??

Chet

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-06 : 07:19:46
Try this

Select count(*) from yourTable where ClaimRef like 'ADKIN%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-06 : 07:20:19
One of these perhaps?

SELECT LEFT(ClaimRef, 5), COUNT(*)
FROM MyTable
GROUP BY LEFT(ClaimRef, 5)

or

SELECT COUNT(*)
FROM MyTable
WHERE ClaimRef LIKE 'ADKIN[0-9][0-9][0-9][0-9][0-9]'

Kristen
Go to Top of Page

ChetShah
Starting Member

37 Posts

Posted - 2005-10-06 : 08:06:32
Thanks Kirsten

your queries work fine

Chet
Go to Top of Page
   

- Advertisement -