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
 Other Forums
 MS Access
 How would I go about constructing this statement?

Author  Topic 

Blastrix
Posting Yak Master

208 Posts

Posted - 2000-12-08 : 20:30:36
I'm trying to figure out the best way to do this. I have a product review
section, which can be broken down to about ten categories. Those categories
get broken down into Manufacturers. The way I have it setup now is with one
table. This table contains the following fields:

category ID
userId
manufacturer
model
review
misc junk
""
""
""

The userId field correlates with the userInfo table, so I'm keeping it in
one DB. What I want to do is display a category, and then split that it
displays one line for each manufacturer that has a product reviewed, but
next to it tells how many review there are for that manufacturer for that
category. Does that make sense? The DB might look like this:

helmets, 23, agv, modelQ, blah, more blah
helmets, 54, agv, ModelX, blah, more blah
leathers, 13, agv, ModelL, blah, more blah
helmets, 27, shoei, RF800, blah, more blah

And it would display like this:

Helmets
AGV(2)
Shoei(1)

I hope that didn't make it confusing. I know I'll have to use DISTINCT for
part of it, so that I can seperate the individual manufacturer names, but I
don't know how exactly to get the number of reviews for said manufacturer. I
could do a seperate query, like SELECT COUNT(*) FROM pr WHERE catId=x and
manufacturer='somebody'
Which I still can't seem to display the total that count found btw. Even so,
I would have to do that statement for every single manufacturer listed,
wouldn't I? Is there a way to do this all in one big query? or am I going to
have to split it up in some fashion? Thanks for actually reading this whole
thing.




   

- Advertisement -