首页 > 其他 > 详细

9_查询之having

时间:2015-05-20 18:44:56      阅读:174      评论:0      收藏:0      [点我收藏+]
select 5种子句:
	where 条件查询
	group by 分组
	having 筛选
	order by 排序
	limit 限制结果条数

---------------------

having

where是对表起作用,
而having是对已查询出来的结果进行筛选

查询出本店商品价格比市场价格小200的商品:
select goods_name,market_price - shop_price as sheng from goods having sheng>200;


查询出本店中栏目为3的商品价格比市场价格小200的商品:
select cat_id,goods_name,market_price -shop_price as sheng from goods where cat_id=3 having sheng>200;


查询积压货款超过2w的栏目,以及该栏目积压的货款
select cat_id,sum(shop_price * goods_number) as hk from goods group by cat_id having hk>20000;


9_查询之having

原文:http://1154179272.blog.51cto.com/10217799/1653235

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!