1. having与group by联合使用,用于分组后的筛选
eg:查询订单按渠道分组后订单总金额大于1000的渠道
SELECT regagent,sum(amount) as total FROM `cy_pay_ok` group by regagent having total>1000 ;
2. having不用group by联合使用,与where类似
eg: 查询单笔订单充值金额大于1000的
SELECT regagent,amount FROM `cy_pay_ok` having amount>1000 ;
SELECT regagent,amount FROM `cy_pay_ok` where amount>1000 ;
两个查询结果一样