answersLogoWhite

0

The short answer is that the WHERE clause is used for comparing values in the base table, whereas the HAVING clause can be used for filtering the results of aggregate functions in the result set of the query. SELECT * FROM tablename WHERE ID > 100 ...is an example of a WHERE clause. Here's a simple example of a HAVING clause that returns the count of workers with the same last names... SELECT WorkerLastName, COUNT(WorkerLastName) AS WorkerCount FROM tblWorker GROUP BY WorkerLastName HAVING COUNT(WorkerLastName) > 1 The HAVING clause allows you to filter the results of aggregate functions, such as COUNT() or AVG() or SUM(), or MAX() or MIN(), just to name a few. HAVING provides you a means to filter these results in the same query, as opposed to saving the results of a WHERE clause SQL statement to a temporary table and running another query on the temporary table results to extract the same results. To do the HAVING SQL above without the HAVING clause would require the following SQL: SELECT WorkerLastName, COUNT(WorkerLastName) AS WorkerCount INTO TempTable FROM tblWorker GROUP BY WorkerLastName SELECT * FROM TempTable WHERE WorkerCount > 1 DROP TABLE TempTable

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

What is the difference between a statement and a clause in SQL?

An SQL statement is a complete set of clauses which returns a value and ends with a semicolon(;) A statement is made up of several clauses Ex: select * from person where f_name='me'; In this ex ' select * from person where f_name='me';' is the statement and select*, from person, where f_name= are the clauses


What is the difference between T-sql and sql?

T-SQL is Microsoft's version of the generic SQL langauge to be used with, for example, Microsoft SQL Server.


What is the difference between hql and sql?

one of the difference is HQL does not support distinct but SQL supports the distinct in the query


Difference between sql and sql plus?

SQL*PLUS is a interface between user and Oracle database. It Provide an environment to use the SQL which is a query language to communicate with oracle database


Difference between sql server 2003 sql server 2005?

There is no such thing as SQL Server 2003. Microft released SQL Server 2005 as the next version of SQL Server 2000.


What is the difference between quel SQL and qbe?

gand maro...is the answer


Difference between SQL Exception class and SQL Warning class?

sql exception which provides information on database access errors where as sql warning provides inforamation on database access warnings.


Difference between oracle 10g and sql in points?

god only knows


Which date function is used to find the difference between two dates in SQL?

datediff


What are difference between cache database and sql database?

CACHE is multidimensional and postconsonantal database and its supporting scripting


Difference between sql function and sql procedure?

Function is must be return the value but procedure cannot be returned, for more information please visit the link : http://youropensource.com


Difference between roll back and commit in sql?

in sql commit is used for saving the changes made in database and roll back is to roll back them , changes will not get saved in the database