weekly report

  • I need to run a report on a weekly basis satrting from july 17th to oct2nd.

    I need to consider july 17th to july 23rd as first week and july 24th to july 30th as second week.

    I need to generate a report for the count of logins to a website on a weekly basis. How can I do that?

     

    Thanks.

     

  • We need the tables ddl, sample data and required output to answer that one.

  • SELECT Count(logins)

    FROM ....

    GROUP BY (DATEDIFF(dd, '2005-07-17', DateOfLogin)/7)

    "DateOfLogin" - column in your table

     

    _____________
    Code for TallyGenerator

  • Here's a link that has a user-defined function that returns that first day of the week for any given input date:

    http://www.sql-server-helper.com/functions/get-first-day-of-week.aspx

    To use it to count for the number of logins on a weekly basis, your query can look like this:

    SELECT [dbo].[ufn_GetFirstDayOfWeek] ( [LoginDateTime] ), COUNT(*)

    FROM YourTable

    GROUP BY [dbo].[ufn_GetFirstDayOfWeek] ( [LoginDateTime] )

    ORDER BY [dbo].[ufn_GetFirstDayOfWeek] ( [LoginDateTime] )

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

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