Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sum if mysql

Posted on 2012-03-20
1
Medium Priority
?
318 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
[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
1 Comment
 
LVL 24

Accepted Solution

by:
johanntagle earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

597 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