我正在尝试以下查询用于计算/报告目的,但它给出了错误。
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