日期:2014-05-17 浏览次数:21017 次
select a.xf_vipcode,xf_surname,xf_telephone,xf_address1,xf_sex,
xf_dob,xf_jointdate,
SUM(a.xf_bonus) AS 当前积分 ,
SUM(a.xf_amount) AS 购买金额 ,
SUM(t.xf_bonus) AS 历史积分
FROM XF_VIP,XF_BONUSLEDGER a,XF_BONUSLEDGER t
WHERE (a.xf_vipcode BETWEEN '000000004' AND '600010651')
AND t.xf_vipcode = a.xf_vipcode
AND (a.xf_vipcode = xf_vip.xf_vipcode)
AND t.xf_bonus>0
GROUP BY a.xf_vipcode,xf_surname,xf_telephone,xf_address1,xf_sex,
xf_dob,xf_jointdate
ORDER BY a.xf_vipcode ;
select a.xf_vipcode,
xf_surname,
xf_telephone,
xf_address1,
xf_sex,
xf_dob,
xf_jointdate,
SUM(a.xf_bonus) AS 当前积分,
SUM(a.xf_amount) AS 购买金额,
SUM(case
when a.xf_bonus > 0 then
a.xf_bonus
else
o
end) AS 历史积分
FROM XF_VIP, XF_BONUSLEDGER a