Total Count - This should be easy.

  • I want to get the total count each of the items of a column. So for instance I have data like this.

    SalesPerson SaleAmount SaleDate

    ----------- ----------- --------

    Fred 100.00 12/02/11

    Jim 20.00 12/03/11

    Steve 116.00 01/02/12

    Fred 28.00 01/06/12

    Jim 45.00 01/06/12

    Fred 18.00 01/07/12

    The Result I want would be...

    Fred 3

    Jim 2

    Steve 1

    I tried this but all I get is the total of all sales. Can someone help?

    SELECT COUNT(DISTINCT SalesPerson) FROM Sales

  • Hi,

    You need to use the GROUP BY clause

    Select SalesPerson , count(*)

    from Sales

    Group by SalesPerson



    Clear Sky SQL
    My Blog[/url]

  • Yes that works perfect! Thanks.

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

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