Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 469595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:47:54+00:00 2026-05-12T23:47:54+00:00

Yeah, so I’m filling out a requirements document for a new client project and

  • 0

Yeah, so I’m filling out a requirements document for a new client project and they’re asking for growth trends and performance expectations calculated from existing data within our database.

The best source of data for something like this would be our logs table as we pretty much log every single transaction that occurs within our application.

Now, here’s the issue, I don’t have a whole lot of experience with MySql when it comes to collating cumulative sum and running averages. I’ve thrown together the following query which kind of makes sense to me, but it just keeps locking up the command console. The thing takes forever to execute and there are only 80k records within the test sample.

So, given the following basic table structure:

id   | action | date_created
1    | 'merp' | 2007-06-20 17:17:00
2    | 'foo'  | 2007-06-21 09:54:48
3    | 'bar'  | 2007-06-21 12:47:30
... thousands of records ...
3545 | 'stab' | 2007-07-05 11:28:36

How would I go about calculating the average number of records created for each given day of the week?

day_of_week | average_records_created
1           | 234
2           | 23
3           | 5
4           | 67
5           | 234
6           | 12
7           | 36

I have the following query which makes me want to murderdeathkill myself by casting my body down an elevator shaft… and onto some bullets:

SELECT
    DISTINCT(DAYOFWEEK(DATE(t1.datetime_entry))) AS t1.day_of_week,
    AVG((SELECT COUNT(*) FROM VMS_LOGS t2 WHERE DAYOFWEEK(DATE(t2.date_time_entry)) = t1.day_of_week)) AS average_records_created
FROM VMS_LOGS t1
GROUP BY t1.day_of_week;

Halps? Please, don’t make me cut myself again. :'(

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:47:55+00:00Added an answer on May 12, 2026 at 11:47 pm

    How far back do you need to go when sampling this information? This solution works as long as it’s less than a year.

    Because day of week and week number are constant for a record, create a companion table that has the ID, WeekNumber, and DayOfWeek. Whenever you want to run this statistic, just generate the “missing” records from your master table.

    Then, your report can be something along the lines of:

    select
      DayOfWeek
    , count(*)/count(distinct(WeekNumber)) as Average
    from
      MyCompanionTable
    group by
      DayOfWeek
    

    Of course if the table is too large, then you can instead pre-summarize the data on a daily basis and just use that, and add in “today’s” data from your master table when running the report.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 239k
  • Answers 239k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not at all sure what your question is. You talk… May 13, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer Is it possible to just use the EventArgs datatype raw?… May 13, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer Where do you add the event listener? If you add… May 13, 2026 at 6:55 am

Related Questions

Yeah, so I'm filling out a requirements document for a new client project and
So yeah, I'm a Java guy in this crazy iPhone world. When it comes
Yeah, sorry about asking a stupid n00b question. So I have a C# program.
Yeah, I know this seems like a dumb question, its just a one-off hack
So I have a pointer to an array of pointers. If I delete it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.