I'm pull gaming stats from a database, but I'm having issues with one of the cases and I can't seem to figure out why.
The first two cases work fine, but the last one just returns null. What's strange is when I replace the third case with one of the others and return it as another name I still get null.
What am I missing??
$sql = "select bt.ID, bt.Username, bt.Group, bt.GUID, DATEDIFF(curdate(),STR_TO_DATE(bt.FirstSeen, '%m/%d/%Y')) as FirstSeenDays, bt.FirstSeen, DATEDIFF(curdate(),STR_TO_DATE(bt.LastSeen, '%m/%d/%Y')) as LastSeenDays, bt.LastSeen, bt.Server, bt.IP, cp.id as personid, cp.callsign,
CASE
WHEN ( bt.Kills = 0 ) THEN '0'
ELSE bt.Kills
END AS Kills,
CASE
WHEN ( bt.Deaths = 0 ) THEN '0'
ELSE bt.Deaths
END AS Deaths,
CASE
WHEN ( bt.Kills = 0 AND bt.Deaths <> 0 ) THEN bt.Deaths
WHEN ( bt.Kills <> 0 AND bt.Deaths = 0 ) THEN bt.Kills
WHEN ( bt.Kills <> 0 AND bt.Deaths <> 0 ) THEN bt.Kills/bt.Deaths
END AS KDR
from $blacktomato_db.playerdb bt
LEFT JOIN $command_db.persons cp ON bt.Username = cp.callsign
order by Username asc";