Answers

Question and Answer:

  Home  Database Administrator (DBA)

⟩ Diffrence between a “where” clause and a “having” claus

Answer1

The order of the clauses in a query syntax using a GROUP BY clause is as follows:

select …where..group by…having…order by…

Where filters, group by arranges into groups, having applies based on group by clause. Having is applied with group by clause.

Answer2

In SQL Server, procedures and functions can return values. (In Oracle, procedures cannot directly return a value).

The major difference with a function is that it can be used in a value assignment. Such as:

–system function

Declare @mydate datetime

Set @mydate = getdate()

–user function (where the user has already coded the function)

Declare @My_area

Set @My_area = dbo.fn_getMy_area(15,20)

Answer3

1.”where” is used to filter records returned by “Select”

2.”where” appears before group by clause

3.In “where” we cannot use aggregate functions like where count(*) >2 etc

4.”having” appears after group by clause

5.”having” is used to filter records returned by “Group by”<

6.In”Having” we can use aggregate functions like where count(*) >2 etc there are two more

 132 views

More Questions for you: