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)
 Counting rows from a table

Author  Topic 

anishap
Yak Posting Veteran

61 Posts

Posted - 2008-09-16 : 19:10:53
I have a column called MMREACT with values ranging 0 - 99.

MMREACT
1
8
99
2
7
8
2
1
67
1
10
87
1

Is there any way to count the number of 1's,2's 3's upto 99?.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-16 : 19:20:56
SELECT COUNT(MMREACT) AS MMREACT
FROM YourTable
WHERE MMREACT BETWEEN 1 AND 99
GROUP BY MMREACT

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

anishap
Yak Posting Veteran

61 Posts

Posted - 2008-09-16 : 22:01:40
Well, I had tried the above query.

I want to know how to count rows for change in rows.
For example

MMREACT Count
1 10
2 16
10 5
45 20
76 50
98 23

Can any one help with this?
1
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-16 : 22:03:28
[code]SELECT MMREACT, COUNT(MMREACT) AS CNT
FROM YourTable
WHERE MMREACT BETWEEN 1 AND 99
GROUP BY MMREACT[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

anishap
Yak Posting Veteran

61 Posts

Posted - 2008-09-16 : 22:21:25
Thanks. It is working now.
Go to Top of Page
   

- Advertisement -