我有这个问题:
SELECT A.msisdn, A.times, sum(A.user_usage) as 'usage'
FROM (SELECT S.msisdn, S.times, D.user_usage,
IF (S.times = 0, S.activation_date, S.last_attribution_date) as ref_date,
DATEDIFF(NOW(), IF (S.times = 0, S.activation_date, S.last_attribution_date) ) as days,
D.transdate
from subs S
INNER JOIN daily_usage D ON (S.msisdn=D.msisdn)
where S.status=1) as A
where A.days % 30 = 0
AND A.transdate between A.ref_date AND DATE(now())
AND A.times <= 6
group by A.msisdn, A.times;
我想知道是否有办法在上述陈述中避免使用subselect。
感谢。