By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Collect and show one type?

P: 80
Hi All!
I have a product catalogue in MSSQL, now I would like to make a function that search the database and shows a list of each brands and how many rows the brand have been found.

Something like:
Acer (33)
Sony(15)
.. And so on..

Can anyone picture me the best way to do so?

Regards.
Frederik
Jan 10 '11 #1

✓ answered by Rabbit

You mean like a count grouping by brand?
Expand|Select|Wrap|Line Numbers
  1. SELECT Brand, Count(*) FROM Table1 GROUP BY Brand

Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,370
You mean like a count grouping by brand?
Expand|Select|Wrap|Line Numbers
  1. SELECT Brand, Count(*) FROM Table1 GROUP BY Brand
Jan 10 '11 #2

P: 80
Well yeah, but it has to be a function that search for any brands in the column "Brands" and then Counts how many of these there are. So I wouldnt need to specify which brands to count beforehand..
Jan 12 '11 #3

Rabbit
Expert Mod 10K+
P: 12,370
You don't have to specify which brands to count beforehand.
Jan 12 '11 #4

P: 80
Guess i'm a little confused. Im not sure how to print the values?
Jan 12 '11 #5

Rabbit
Expert Mod 10K+
P: 12,370
You would probably just loop through the recordset and write the values.
Jan 12 '11 #6

P: 80
I see now Thanks.
Jan 12 '11 #7

Post your reply

Sign in to post your reply or Sign up for a free account.