Solved

count question

Posted on 2012-03-15
3
267 Views
Last Modified: 2012-03-15
Hi

I am trying to do a count of the total number of help desk calls for the last 30 days grouped within the last 8 days.

So my calculation would need to go based on the following

08/03/2012 -  "Count all the calls within the last 30 days from this date"
09/03/2012 -  "Count all the calls within the last 30 days from this date"
10/03/2012 -  "Count all the calls within the last 30 days from this date"
etc

My calls are logged by in unixtime and I can count the calls by their ID.
I am running mysql 4.0.16
Thanks
0
Comment
Question by:Dan560
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Expert Comment

by:johanntagle
ID: 37724052
try:

select count(ID) from table where column_name between unix_timestamp('2012-03-8') and unix_timestamp(date_add('2012-03-08'), interval 30 day);
0
 
LVL 2

Author Comment

by:Dan560
ID: 37724168
I was thinking more a long the lines of this command that I found
Source: http://www.joellipman.com/articles/sql/mysql/457-sql-queries-for-statistics.html

SUM(IF((HOUR(a.DateTimeStamp) BETWEEN 8 AND 18), 1, 0)) 'Worktime',

I was thinking of modifying so that it is between the logdate and the past 30 days. However I am not sure how to modify it so that it does this.
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 37724185
what exactly is the datatype of DateTimeStamp?  Is it Datetime or integer (for timestamp from unix epoch) ?

If it's datetime it can be something like:

sum(if(a.DateTimeStamp between '2012-03-08' and '2012-04-08', 1, 0))

I however do not really recommend it, as it likely won't make use of indexes on DateTimeStamp, if any.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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