
September 10th, 2012, 03:21 PM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 5
Time spent in forums: 28 m 16 sec
Reputation Power: 0
|
|
|
HELP with COMPLEX COUNT/CASE
Hey guys, I am having trouble with the following:
COUNT( CASE WHEN xferleads.timestamp >= wo_date
AND xferleads.timestamp <= wo_end_date
THEN xferleads.customer
ELSE NULL END ) AS countslw
This works well except under one condition:
There are times when wo_end_date is NULL and under such a condition the count is obviously 0
I assume the solution is a nested CASE but I am having trouble with the syntax.
In other words - count how many xferleads.timestamp there are between wo_date and wo_end_date. If wo_end_date is NULL, count SINCE wo_date only.
|