不错,学习了 |
mark,学习 |
select distinct e.theyear, e.itemid, f.maxofamount from (select c.theyear, b.itemid, sum(b.amount) as sumofamount from tbStock a, tbStockDetail b, tbDate c where a.ordernumber = b.ordernumber and a.dateid = c.dateid group by c.theyear, b.itemid) e, (select d.theyear, max(d.sumofamount) as maxofamount from (select c.theyear, b.itemid, sum(b.amount) as sumofamount from tbStock a, tbStockDetail b, tbDate c where a.ordernumber = b.ordernumber and a.dateid = c.dateid group by c.theyear, b.itemid) d group by d.theyear) f where e.theyear = f.theyear and e.sumofamount = f.maxofamount order by e.theyear; this is good |
赞,提供数据就好了 |
很详细的资料 |
感谢分享 |