首页 > 代码库 > HAVING与WHERE的区别

HAVING与WHERE的区别

SELECT store_name,SUM(sales)

FROM Store_Information

GROUP BY store_name

HAVING SUM(salse)>1500

SELECT COUNT(store_name)

FROM Store_Information

WHERE store_name is not NULL

SELECT store_name

FROM Store_Information

WHERE Sales>1000

HAVING是对函数产生的值来设定条件

WHERE是对函数的变量来设定条件

WHERE给出的是SELECT的条件,即选择栏位的条件,这个条件一般是由某个栏位名来表达、决定

 

HAVING与WHERE的区别