Collect and show one type?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pheddy
    New Member
    • Dec 2008
    • 80

    Collect and show one type?

    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
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You mean like a count grouping by brand?
    Code:
    SELECT Brand, Count(*) FROM Table1 GROUP BY Brand

    Comment

    • Pheddy
      New Member
      • Dec 2008
      • 80

      #3
      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..

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You don't have to specify which brands to count beforehand.

        Comment

        • Pheddy
          New Member
          • Dec 2008
          • 80

          #5
          Guess i'm a little confused. Im not sure how to print the values?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            You would probably just loop through the recordset and write the values.

            Comment

            • Pheddy
              New Member
              • Dec 2008
              • 80

              #7
              I see now Thanks.

              Comment

              Working...