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.
| Author |
Topic |
|
dazmiller
Starting Member
2 Posts |
Posted - 2005-09-19 : 20:27:11
|
| ok a dumb one here but i need some help.I have records as such in access dbName ID StatusCodeName is a list of namesID is an ID funnily nuffStatusCode is a string that can be any of 50 different values.So i have records like thisName ID StatusCodeDan 1 05Mary 2 25Dan 1 25Dan 1 25I need a query to do the following:For each name how many 05's are there, how many 25's etc.so the result should be something like:Dan 05 Result : 1Dan 25 Result : 2Mary 05 Result : 1Basically i need the count of rows for each person that match the statuscode.Any ideas? |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-09-19 : 22:32:56
|
| can you post your initial query and tell us where you're encountering an error...--------------------keeping it simple... |
 |
|
|
dazmiller
Starting Member
2 Posts |
Posted - 2005-09-19 : 23:08:28
|
| Hi, thanks for the reply.That is the difficult part.How do i do this query.Using access will i have to write some code to iterate thru all the values for one field and query on it. IE (mnemonics) get all the distinct names, then for each name query the count of certain statuscode?Sorry i am not much help here, its got me stumped. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-09-19 : 23:23:14
|
ok, try reading select query with group by clause on (name or id) and statuscode, also read count functionin books onLine, you should be fine with this, oh btw, you may want to check Kristen's sticky in the newbie forum, lots of codes there with regards to grouping data --------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-20 : 02:08:27
|
| Try thisSelect Name,StatusCode, count(*) as Counting from yourTable group by Name,StatusCodeMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|