How to row count per group in a single query?

  • I would like to return a row count of each group for several groups returned a single query. I am not summing a numeric value in the rows, I just want an individual row count displayed for each group. My query is below. With the group by I return 1600 rows, without 250,000

    select author

    from profile profile inner join

    matter matter on profile.matter = matter.system_id

    where client_id = '3999' and matter_id = '1'

    group by author

    thanks

  • Use COUNT(*) will give you a row count, adding author will give based on related author in grouping. Can you give us an example of what you have to start with, what you get and what you want if COUNT(*) does not meat your needs.

  • You mean something like this?

    select author, count(*)

    from profile inner join

    matter on profile.System_id = matter.system_id

    where client_id = '3999' and matter_id = '1'

    group by author

    John Zacharkan


    John Zacharkan

  • This did it. Thank you much

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply