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)
 stored proc help

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2003-01-30 : 05:07:27

Just wondering if I can get some help here, I haven't done a query like this before and I'm a little stuck.

I have a table with the following columns

ModID
userID
photoID
approved
dateApproved

This is a transactional table, each time .
What I want to do is return the COUNT of each rows for each ModID

example returned data

mod 1000 = 500 rows counted
mod 2000 = 23423 rows counted

How can I go about this? I would actually like to go even more in depth if its not too hard as well. I would like the above data returned, but also broken down by the approved columns possible 2 values of either 0 or 1 .

example
mod 1000 = 260 rows of approved = 0
mod 1000 = 240 rows of approved = 1


Thanks alot for any insight

Mike123

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2003-01-30 : 07:24:14
are u looking for something like this?
select count(*) as 'mod 1000' from table where mod=1000
select (*)as 'mod 2000' from table where mod=2000

I am not sure if i have understood u'r question properly;?

Expect the UnExpected
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-01-30 : 07:29:37
How about this:

SELECT ModID, Approved, COUNT(*) FROM ModTable GROUP BY ModID, Approved


OS

Go to Top of Page
   

- Advertisement -