Toatal count

  • I have the following fields in my table.

    UserName DateTime Action

    abc 22/1/2011 23:45 xyz

    abc 23/1/2011 10:00 pqr

    abc 23/1/2011 15:00 pqr

    abc 23/1/2011 20:00 pqr

    abc 23/1/2011 21:00 pqr

    cde 23/1/2011 55:00 rst

    I need to know particular user has paerformed particular action between specified time with count

  • can you give us a sample result set/output that you want to achieved?

    "Often speak with code not with word,
    A simple solution for a simple question"

  • Cannot able to understand properly may be

    this query will work

    declare @username varchar(10),@fromdate datetime ,@todate datetime;

    select username,ACTION,COUNT(action) from table1

    where username=@username and datetime between @fromdate and datetime

    group by username,ACTION

    this gives output for particular user ,performed particular actions with specific time

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • chintalapati.srikanth (12/30/2011)


    I have the following fields in my table.

    UserName DateTime Action

    abc 22/1/2011 23:45 xyz

    abc 23/1/2011 10:00 pqr

    abc 23/1/2011 15:00 pqr

    abc 23/1/2011 20:00 pqr

    abc 23/1/2011 21:00 pqr

    cde 23/1/2011 55:00 rst

    I need to know particular user has paerformed particular action between specified time with count

    SELECT USERNAME, COUNT(1) COUNTER

    FROM YOUR_TABLE

    WHERE USERNAME= 'ABC' -- PARTICULAR USER

    AND ACTION = 'XYZ' --PARTICULAR ACTION

    AND DATETIME >= 'SOME_DATE' AND DATETIME < 'SOME_DATE' --BETWEEN SPECIFIED TIME

    GROUP BY USERNAME

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

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