計算/レポートの目的で次のクエリを試していますが、エラーが発生しています。
SELECT c.idx, c.club_name, s.sale_event_date,
COUNT(s.*) AS total_guests,
(SELECT COUNT(s.*) FROM sales s WHERE t2.qr_scanned = 1 AND t2.sale_event_date = s.sale_event_date) AS total_scanned_guests,
SUM(s.rep_sale_commission) AS total_rep_commission,
SUM(s.sale_commission) AS total_admin_fees
FROM club c
LEFT JOIN sales s ON s.club_id = c.idx
WHERE c.admin_id = 37
GROUP BY s.sale_event_date
ORDER BY sale_event_date DESC
エラーは次のとおりです。
use near '*) AS total_guests, (SELECT COUNT(s.id) FROM sales s WHERE t2.qr_scanned = 1 AN' at line 2