在SQL SERVER 2008中拥有子句 [英] Having Clause in SQL SERVER 2008
本文介绍了在SQL SERVER 2008中拥有子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
having子句和where子句有什么区别?
推荐答案
Because we can not use Where clause with <b>aggregate functions </b>like <b>count(),min(), sum()</b> etc. so <b>having clause</b> came into existence to overcome this problem in sql. see example for having clause go through this link
http://www.sqlfundamental.com/having-clause.php
使用Group by和aggregate函数。你可以在直接列中使用。
例如:
Having works with Group by and aggregate function. And where you can use in direct column.
For Example:
SELECT Item_Code,Item_Description,UOM
FROM Products
WHERE Item_Description like '%book%'
GROUP BY Item_Code,Item_Description,UOM
HAVING UOM = 'Each'
希望这会有所帮助..
Hope this will help..
这篇关于在SQL SERVER 2008中拥有子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文