Solved

sum if mysql

Posted on 2012-03-20
1
267 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

19 Experts available now in Live!

Get 1:1 Help Now