|
Title: Differentiate b/n WHERE and HAVING BY Post by: unknown on December 14, 2007, 08:29:32 am Hi all
Can anyone please differentiate between WHERE and HAVING BY clause...? When each of them can be used ? Help is appreciated.... Thanks in Adv. Title: Re: Differentiate b/n WHERE and HAVING BY Post by: ragjeevan on February 18, 2010, 01:01:41 pm Where is a filter executed at row level
Having by is a filter that is executed over aggregated data. Title: Re: Differentiate b/n WHERE and HAVING BY Post by: sanjay81 on May 05, 2010, 01:15:16 am HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.
Where is used to restrict the rows having is used to restrict the group. ;) Title: Re: Differentiate b/n WHERE and HAVING BY Post by: shanilr on May 18, 2010, 02:21:09 pm Hi Sanjay,
First of all you can use HAVING clause only with the Group by clause. So therefore Having clause is used to limit the records which are grouped based on the specified columns. In a typical SQL statement WHERE clause gets executed first and then SQL processes Group by and Having clause. So Where clause can be used to filter out the records which are not needed for the Group by clause and then Having clause can be used to display only those records which meets the required condition after grouping. |