What is the difference between HAVING clause and the WHERE
clause?

Answer Posted / mayursinh zala

'Where' clause applies to the individual rows whereas 'Having' clause is used to test some condition on the group(usually aggregate methods) rather than on individual rows.

Specifies a search condition for a group or an aggregate. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.

So you can use having WITHOUT group by clause. This is a sample, although it might make no sense of business value:


select max(state) from States having count(State) > 60

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is similarity and difference between truncate and delete in sql?

595


How can I get data from a database on another server?

517


Introduction of rollup clause using sum and group by clause?

542


how you can move data or databases between servers and databases in sql server? : Sql server administration

489


What are the restrictions applicable while creating views? : SQL Server Architecture

590






What is the maximum size per database for sql server express?

561


What is ems sql management studio? : sql server management studio

592


What is the difference between ddl,dml and dcl commands?

614


What is global temp table?

567


How can we delete a table in sql server?

559


What are “lock” hints?

595


Can we use where clause in union?

599


What are the five major components of a dbms?

518


You want to implement the one-to-many relationship while designing tables. How would you do it?

514


What does truncate do?

535