分组数据
2019-08-05 本文已影响0人
骑着白龙马的猪八戒
group by 创建分组 出现在where子句之后,order by子句之前
having
select vend_id,count(*) as num_prods from products group by vend_id;
GROUP BY语句只是MYSQL按照vend_id排序并分组
![](https://img.haomeiwen.com/i13805608/329f52007806df17.png)
排序和分组
mysql> select order_num,sum(quantity*item_price) as ordertotal from orderitems group by order_num having sum(quantity*item_price)>=50
![](https://img.haomeiwen.com/i13805608/821eafe5e8eb4ee4.png)