Thursday, 22 March 2018

Having clause

Having clause
Having clause is similar to the where clause but it is used in the conjuction with group by clause in select statement
Group by clause with having clause used to filter the data or recordset.

Having clause folloed by group by and preced order by clause if used.

Following is the position of having clause

Select
From
Where
Group by
Having
Order by

Eg.
select TitleOfCourtesy from Employees
group by TitleOfCourtesy,BirthDate
having BirthDate >= CONVERT(datetime,'1950-10-12',101)


select TitleOfCourtesy from Employees
group by TitleOfCourtesy,BirthDate

having BirthDate >= '1960-10-12'

No comments:

Post a Comment