You are on page 1of 1

The group by clause group the row of a result set based on one or more columns of expressions.

It
typically used in select statement that include aggrate function the aggregrate is calculated for each set
of value that result from the column named in the group the clause.

A group by list typically consists of the names one or more columns seprarted by comma.

The having clause specifies a search condition for a group are an aggregate. This condition is apply after
the rows that satisfy the search condition in the where clause or group.

Syntax:

SELECT select-list

from Tablename

[where search condition]

[group by group-list]

[having search cond]

[order by orderi ng-list]

Difference between where and having clause

1.When you include a where clause in a select statement that uses grouping and aggregates, the search
condition is applied before the rows or groups and the aggregates are calculated. That way only the
rows that satisfy the search conditions and group are summarise.

1.When you incliuded a have clause in a select statement the uses grouping and aggregates, the search
condition is applied after the rows or groups and the aggregates are calculated. That way only the
groups that satisfy the searc h conditions are included in the result set.

2.A having clause can only refer to a column included in a select or grop by clause.

2.A where clause can refer to any column in the base table.

3.aggregate function can only the coded in a having clause.

3. A where clause can not contain aggerate function.

http://www.amulyam.in/dsQuizN.do?quizId=133782&name=Cricket

You might also like