Solved

sum if mysql

Posted on 2012-03-20
1
278 Views
Last Modified: 2012-03-21
Hi I am trying to do a calculation of the number of helpdesk calls that are open at the end of the day.

I am using the following

sum(if(FROM_UNIXTIME(maindb.closedatex,"%Y-%m-%d") > dates.date,1,0 ))

This checks if the close date of the call is greater than my date field. However if a call is still open then the closdate is displayed as "1970-01-01"

Does anyone know how I can add this into the statement above?
0
Comment
Question by:Dan560
1 Comment
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 37745157
if i understand you right you need

sum(if(FROM_UNIXTIME(maindb.closedatex,"%Y-%m-%d") > dates.date or maindb.closedatex=0, 1,0 ))

0 because 1970-01-01 00:00:00 translates to that in unix_timestamp.  or you can also do

"or from_unixtime(maindb.closedatex,'%Y-%m-%d') = '1970-01-01'"
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

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…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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