Solved

count question

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 56
running code or pseudo code of table structure 5 30
unable to insert record into a table 2 37
Combining Queries 7 27
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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