sum of distinct records

  • the data (simplied) look like this:

    Name             date

    AAA                1/1/2005

    AAA                 1/1/2005

    BBB                  1/1/2005

    CCC                  1/1/2005

    BBB                   1/2/2005

    BBB                    1/2/2005

    I want to see how many unique users in a day. the result should be like

    3                      1/1/2005

    1                      1/2/2005

    is it possible to achieve that without using cursor?

    thanks a lot!!!

     

     

  • Maybe try something like this:

    select count(Name),date from(select distinct Name,date from testing)A group by date

     

    hope that helps.

  • Simplified a touch:-

    select COUNT(DISTINCT(Name)) FROM

    Have fun

    Steve

    We need men who can dream of things that never were.

  • As per Steve's answer.

    Easiest way:

    select count(distinct(name)), date

    from testing

    group by date

     


    ------------------------------
    The Users are always right - when I'm not wrong!

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

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