Sorting and counting problem

Results 1 to 2 of 2

Thread: Sorting and counting problem

  1. #1
    Join Date
    Dec 1969

    Default Sorting and counting problem

    Hi,<BR>I can only explain my question by an example.<BR><BR>Assume I have a single column in an Access table that includes the various colors of, say, some widgets I have produced (assume I&#039ve produced 7 widgets and recorded their colors in my table). Now I want to write a program to output the number of times each of the various color widgets were produced. So, assume the table has the following widget colors in a column:<BR><BR><BR>Black<BR>Blue<BR>Black<BR>Green <BR>Blue<BR>Red<BR>Black<BR><BR>The program I want to write would output the following:<BR>3 Black<BR>2 Blue<BR>1 Geen<BR>1 Red<BR><BR>Any ideas how to go about this? Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: Sorting and counting problem

    SELECT Count(*), WidgetColor FROM WidgetTable<BR>GROUP BY WidgetColor<BR><BR>*******<BR><BR>That&#039s all. Really. GROUP BY holds all the magic.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts