| 3 |
"query": "\n SELECT p.id AS \"id: ProjectId\", p.title, COALESCE(SUM(t.amount_cents), 0)::BIGINT AS \"revenue!\"\n FROM projects p\n LEFT JOIN items i ON i.project_id = p.id\n LEFT JOIN transactions t ON t.item_id = i.id AND t.status = 'completed'\n WHERE p.user_id = $1\n GROUP BY p.id, p.title\n HAVING COALESCE(SUM(t.amount_cents), 0) > 0\n ORDER BY COALESCE(SUM(t.amount_cents), 0) DESC\n ", |