Solved

count question

Posted on 2012-03-15
3
264 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

18 Experts available now in Live!

Get 1:1 Help Now