Home Forums SQL Server 7,2000 T-SQL count number of rows per hour per client and in the end total RE: count number of rows per hour per client and in the end total

  • You're looking for something like this?

    Declare @StartTimedatetime,

    @EndTimedatetime,

    @Totalint

    SELECT Client, datepart(hh, YourDate) HourNumber, SUM([NumRows]) VRowCount

    INTO #1

    FROM YourTable

    WHERE YourDate BETWEEN @StartTime and @EndTime

    GROUP BY Client, datepart(hh,YourDate)

    SET @Total = (SELECT SUM(VRowCount)

    FROM #1)

    SELECT Client, HourNumber, VRowCount, @Total TotalRows

    FROM #1

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]