如何在注册时使用DISTINCT使以下$query工作.Quiz_id以消除双三重记录


How can i make the following $query work Using DISTINCT on Enrollments.Quiz_id to get rid of the double-triple records

SELECT SUM(ticketfee * enrolledplayers)
FROM Quiz
 INNER JOIN Enrollment on DISTINCT(Quiz.id) AND Quiz.id=Enrollment.Quiz_id
WHERE (Quiz.state=3 OR Quiz.state=4) AND Enrollment.promocoupon_id IS NULL
SELECT DISTINCT(Quiz.id), SUM(ticketfee * enrolledplayers)
FROM Quiz
JOIN Enrollment on Quiz.id = Enrollment.Quiz_id
WHERE (Quiz.state=3 OR Quiz.state=4) AND Enrollment.promocoupon_id IS NULL