ridvan
ridvan

Reputation: 743

Count once time smilar id in sql

My aim is to count according to the id once time same id It doesn't count every id each time.

I used this:

Select count Where id=1 between 1000;

but it counts to smilar id more than one.

Upvotes: 0

Views: 68

Answers (2)

Nayeem Mansoori
Nayeem Mansoori

Reputation: 831

Have you try this : Count with ID like this

SELECT COUNT(ID) FROM dbo.TableName WHERE ID BETWEEN 1 AND 1000

Upvotes: 0

Barmar
Barmar

Reputation: 780889

Use DISTINCT

SELECT COUNT(DISTINCT id)
FROM YourTable
WHERE id BETWEEN 1 AND 1000

Upvotes: 2

Related Questions