以下是引用wwwwa在2006-9-7 14:38:00的发言:
try:
select a.卡号, a.姓名,a.ma,count(*) as pm from (
SELECT 卡号, 姓名, sum(消费金额) as ma
FROM 表1 group by 卡号, 姓名) a left join
(SELECT 卡号, 姓名, sum(消费金额) as ma FROM 表1 group by 卡号, 姓名) b
on a.ma<=b.ma
group by a.卡号, a.姓名,a.ma
order by 4
以下是引用wwwwa在2006-9-8 8:07:00的发言:
你自己改造一下,
SELECT a.卡号, a.姓名, a.ma, a.cs, count(*) AS pm
FROM (SELECT 卡号, 姓名, sum(消费金额) as ma,count(*) as cs
FROM 表1 group by 卡号, 姓名) AS a LEFT JOIN (SELECT 卡号, 姓名, sum(消费金额) as ma FROM 表1 group by 卡号, 姓名) AS b ON a.ma<=b.ma
GROUP BY a.卡号, a.姓名, a.ma, a.cs
ORDER BY 4;
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |