Displaying a total from current year data only
I have a DA page which displays training course details for users as follows:
SELECT *,SUM(CPD.Minutes) FROM users LEFT JOIN CPD on users.id = CPD.User_ID GROUP BY users.display_name ORDER BY users.display_name ASC
I then have a field in the results table which displays the number of training hours undertaken by each individuals as follows:
<?php echo round($rsUsers->getColumnVal("SUM(CPD.Minutes)")/60,2); ?>
However, I only want this to display the total hours from the current year, rather than an overall total. I tried adding another WHERE clause to the query which would only select dates from the current year, however this also then means that if someone hasn't done any training yet this year, they won't be displayed at all. How would I display only the total hours from the current year, maybe using a PHP IF statement instead?