美文网首页
oracle中having的用法

oracle中having的用法

作者: 荀彧真人 | 来源:发表于2017-07-20 16:21 被阅读0次

在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用。

#查询订单总金额少于2000的客户
select name, sum(price) from tableA group by name having sun(price)>10000
#查找用户张三或者李四,订单总金额超过20000的订单总金额
select name, sum(price) from tableA where name = 'zhangsan' or name = 'lisi' group by name having sum(price) > 20000

相关文章

网友评论

      本文标题:oracle中having的用法

      本文链接:https://www.haomeiwen.com/subject/bvqjkxtx.html