• I think you need to be a little more clear about your expected output. To help out, here is you sample data in consumable form.

    WITH SampleData AS

    (

    SELECT userid, [date], usage

    FROM

    (

    VALUES ('cjohn','2013/10/01 00:30:00',5)

    ,('fpears','2013/10/03 00:11:00',2)

    ,('cjohn','2013/10/04 12:30:45',3)

    ,('kthomas','2013/10/04 13:20:11',3)

    ,('cjohn','2013/10/04 14:10:10',2)

    ,('rpeter','2013/10/04 18:01:01',3)

    ,('cjohn','2013/10/04 19:10:01',10)

    ,('fpears','2013/10/06 19:11:11',11)

    ,('cjohn','2013/10/07 10:11:03',20)

    ,('rpeter','2013/10/09 05:10:05',11)

    ,('fpears','2013/10/11 06:10:15',6)

    ,('cjohn','2013/10/14 13:11:11',7)

    ,('kthomas','2013/10/16 08:10:10',6)

    ) a (userid, [date], usage)

    )

    SELECT userid, [date]=CAST([date] AS DATE), usage

    FROM SampleData;

    Now taking a look just at userid=cjohn, his records appear as follows:

    userid date usage

    cjohn 2013-10-01 5

    cjohn 2013-10-04 3

    cjohn 2013-10-04 2

    cjohn 2013-10-04 10

    cjohn 2013-10-07 20

    cjohn 2013-10-14 7

    So his average daily usage over the period 01-Oct to 14-Oct is going to be different than if these are his only records for all of 2013.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St