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 |
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 reviewsection, which can be broken down to about ten categories. Those categoriesget broken down into Manufacturers. The way I have it setup now is with onetable. This table contains the following fields:category IDuserIdmanufacturermodelreviewmisc junk""""""The userId field correlates with the userInfo table, so I'm keeping it inone DB. What I want to do is display a category, and then split that itdisplays one line for each manufacturer that has a product reviewed, butnext to it tells how many review there are for that manufacturer for thatcategory. Does that make sense? The DB might look like this:helmets, 23, agv, modelQ, blah, more blahhelmets, 54, agv, ModelX, blah, more blahleathers, 13, agv, ModelL, blah, more blahhelmets, 27, shoei, RF800, blah, more blahAnd 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 forpart of it, so that I can seperate the individual manufacturer names, but Idon't know how exactly to get the number of reviews for said manufacturer. Icould do a seperate query, like SELECT COUNT(*) FROM pr WHERE catId=x andmanufacturer='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 tohave to split it up in some fashion? Thanks for actually reading this wholething. |
|
|
|
|
|
|