Mine
public text v1 · immutable $stmt = "SELECT
CASE WHEN sup_iss_id > 0 THEN 'associated' ELSE 'unassociated' END AS type,
COUNT(*) AS total_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email,
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
WHERE
sup_ema_id=ema_id AND
ema_prj_id=$prj_id AND
sup_removed=0
GROUP BY
type";