HQL
select max(o.customer), sum(i.count) // o.customer 出错
from Order o, Item i
where o = i.order
and o.status = 'A:valid'
and i.goods.goodsNo = 4
group by o.customer
SQL
select o.customer_no, sum(i.count)
from order o, item i
where o.order_no = i.order_no
and o.status = 'A:valid'
and i.goods_no = 4
group by o.customer_no
JSTL显示数据
<c:forEach var="list" items="${results}">
<c:out value="${list[0].name}" />
<c:out value="${list[1]}" /> <br>
</c:forEach>
select max(o.customer), sum(i.count) // o.customer 出错
from Order o, Item i
where o = i.order
and o.status = 'A:valid'
and i.goods.goodsNo = 4
group by o.customer
SQL
select o.customer_no, sum(i.count)
from order o, item i
where o.order_no = i.order_no
and o.status = 'A:valid'
and i.goods_no = 4
group by o.customer_no
JSTL显示数据
<c:forEach var="list" items="${results}">
<c:out value="${list[0].name}" />
<c:out value="${list[1]}" /> <br>
</c:forEach>