例如有一张OrderDetail表,结构和数据如下:


例1:统计所有订单的产品数
select orderid,productid,quantity from orderDetail
compute sum(quantity)结果集:

例2:统计每个订单的产品数量
select orderid,productid,quantity from orderDetail
order by orderid
compute sum(quantity) by orderid结果集:

注意:compute by后面的字段必须在order by后面的字段列表中。
评论(0)
暂无评论。