capturing  a count at a specific point in time

Posted on 2014-08-14
Last Modified: 2014-08-19
Good Morning experts,

I have been tasked to do a weekly report based on application usage for each school and then show what percent of the student and teacher poplulation are using the application.  The thing is that the over all population at each school may change from week to week.  I can get the population as of today but I want to capture the population based on the time frame i run the report.  For example if I am looking at app usage from Aug 4 to aug 10 I want to get the student population as of August 4th not as today.  I do have an enrollment delta table I am using.  

SELECT  [deptcode]
  FROM [GSDR].[d2l].[GCPS_OUX_Enrollments_School_delta]

SchCode      empno      orgrole      status      modStatus      modDt
643      200100009      Student      1      1      7/22/2014 23:01
196      200100306      Student      1      1      7/22/2014 23:01
225      200100354      Student      1      1      7/22/2014 23:01
750      200100354      Student      1      1      7/22/2014 23:01
750      200100359      Student      1      1      7/22/2014 23:01
439      200100362      Student      1      1      7/22/2014 23:01
439      200100605      Student      1      1      7/22/2014 23:01

mod status of 1 is enrolled, mod status if 0 is disenrolled the modDt field is the day the modificaton was made.  I tried doing a count a grouping by schCode but the didnt work.
Question by:Butterfly2
    LVL 47

    Accepted Solution

    There isn't sufficient information in that table to give you a "point in time" capability. Although you will know the date/time of a change, you won't then know the date of the former change, or the former change etc etc

    You will need to run a "weekly snapshot" query for "get the population as of today" and store it, with the date/time you ran the weekly snapshot.

    You could run this as a scheduled job once you have the logic sorted out.

    Author Comment

    I have  a job scheduled that populates a table the with the student poplulation daily

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now