Solved

count question

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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 …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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