I have a database query that groups payments due into monthly values.
The problem I am facing now is that I can not see each individual payments to be able to make sure all are paid.
dp within the column is Date Paid.
If the date within the column is 0000-00-00 00:00:00 then no payment has been made.
Here is the query:
$monthlyQuery = $pdo->prepare(" SELECT SUM(net) AS net , MONTH(dd) AS month , YEAR(dd) AS year , dp FROM sin WHERE cpo=:cpo AND dd >= :dd1 AND dd <= :dd2 GROUP BY month ORDER BY dd ASC "); $monthlyQuery->execute(array(':cpo' => $fetch['cpo'], ':dd1' => $janDate, ':dd2' => $decDate)); $monthlyQueryNum = $monthlyQuery->rowCount();
is there a way to check each dp column before the row is grouped and if at any point the date is 0000-00-00 00:00:00 then make all dates for that group 0000-00-00 00:00:00
I was thinking of doing a CASE WHEN THEN but the logic doesn’t seem to work for me.