Hvis vi laver et minimum af alle transaktioner pr. kunde, så tjek om det er i den rigtige periode, vi får noget i retning af...
Dette vil blot give dig et ja/nej-flag om, hvorvidt kundens første køb var inden for perioden...
SELECT CASE COUNT(*) WHEN 0 THEN 'Yes' ELSE 'No' END As [WasFirstTransInThisPeriod?]
FROM (
SELECT bb_member.member_id As [member_id], MIN(bb_transactions.trans_tran_date) AS temp_first_time
FROM bb_business
RIGHT JOIN bb_transactions ON bb_transactions.trans_store_id = bb_business.store_id
LEFT JOIN bb_member ON bb_member.member_id = bb_transactions.trans_member_id
WHERE bb_business.id = '5651'
GROUP BY bb_member.member_id
) T
WHERE T.temp_first_time BETWEEN '2010-08-01' AND '2010-09-13'
ORDER BY T.member_id DESC
(dette er i T-SQL, men skulle forhåbentlig give en idé om, hvordan dette kan opnås tilsvarende i mySQL)
Simon