select count by group?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wilscott1st@yahoo.com

    #1

    select count by group?

    Is it possible in access to select the total count of records for a
    given group of records and show those all those counts in one report?
    For example, I have a table of records that contain different customers
    with different service requests. I would like to build a report that
    shows the quantity of service requests for each customer and then maybe
    later, by type of service request for each customer. Fields are
    CustomerName, ServiceRequestD ate, Type. I can use the query builder and
    know a little SQL and I can make a report for each customer with the
    count in it, but all I'm really interested in is the count for each
    customer, hopefully on 1 report? Thanks for any help....

  • Smartin

    #2
    Re: select count by group?

    wilscott1st@yah oo.com wrote:[color=blue]
    > Is it possible in access to select the total count of records for a
    > given group of records and show those all those counts in one report?
    > For example, I have a table of records that contain different customers
    > with different service requests. I would like to build a report that
    > shows the quantity of service requests for each customer and then maybe
    > later, by type of service request for each customer. Fields are
    > CustomerName, ServiceRequestD ate, Type. I can use the query builder and
    > know a little SQL and I can make a report for each customer with the
    > count in it, but all I'm really interested in is the count for each
    > customer, hopefully on 1 report? Thanks for any help....
    >[/color]

    Try

    SELECT CustomerName, Count(CustomerN ame)
    FROM MyTable
    GROUP BY CustomerName;

    And maybe later

    SELECT CustomerName, Type, Count(Type)
    FROM MyTable
    GROUP BY Type, CustomerName
    ORDER BY CustomerName, Type;

    --
    Smartin

    Comment

    • wilscott1st@yahoo.com

      #3
      Re: select count by group?


      Smartin wrote:[color=blue]
      > wilscott1st@yah oo.com wrote:[color=green]
      > > Is it possible in access to select the total count of records for a
      > > given group of records and show those all those counts in one report?
      > > For example, I have a table of records that contain different customers
      > > with different service requests. I would like to build a report that
      > > shows the quantity of service requests for each customer and then maybe
      > > later, by type of service request for each customer. Fields are
      > > CustomerName, ServiceRequestD ate, Type. I can use the query builder and
      > > know a little SQL and I can make a report for each customer with the
      > > count in it, but all I'm really interested in is the count for each
      > > customer, hopefully on 1 report? Thanks for any help....
      > >[/color]
      >
      > Try
      >
      > SELECT CustomerName, Count(CustomerN ame)
      > FROM MyTable
      > GROUP BY CustomerName;
      >
      > And maybe later
      >
      > SELECT CustomerName, Type, Count(Type)
      > FROM MyTable
      > GROUP BY Type, CustomerName
      > ORDER BY CustomerName, Type;
      >
      > --
      > Smartin[/color]

      Thank-you for assisting me, I was on the right track but the
      parenthisis "COUNT(What i want to count)" threw me. Again, thanks for
      your help.

      Comment

      Working...