Solved

count question

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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