Results 1 to 2 of 2

Thread: Select count of type by person

  1. #1
    Join Date
    Jan 2005

    Select count of type by person

    I have a database table that is a list of items. It has columns for id, type_id, date, staff_id, memo, etc. I'm trying to select the number of items (i.e. using the count() function) of each type per person. So the output table would be like:

    Name: | Count of Type 1: | Count of Type 2 | .......
    Chris | 3 | 2 |
    John | 2 | 1 |

    Any ideas? I think it's a matter of counting the items based on type_id and then grouping them by staff_id, but I can't seem to get it.

    Any help is appreciated! Thanks.

  2. #2
    Join Date
    Jul 2006
    its depends of what u want and use group by as u need
    for example

    PHP Code:
    //change * to what you want count to
    $sql '
    select name, count(*) as countNumber
    from table
    group by itemId 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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