Data Warehousing Community Forum Data Warehousing Community Forum
The Warehouse of Data warehousing knowledge ...
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 31, 2010, 02:35:49 am


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: Differentiate b/n WHERE and HAVING BY  (Read 642 times)
unknown
DW Apprentice
**

Reputation: +7/-0
Offline Offline

Posts: 44



View Profile
« 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.
Logged

Thanks
Unknown Smiley
ragjeevan
DW Fresher
*

Reputation: +1/-0
Offline Offline

Posts: 15


View Profile WWW
« Reply #1 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.
Logged
sanjay81
DW Fresher
*

Reputation: +0/-0
Offline Offline

Posts: 2


View Profile
« Reply #2 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.  Wink
Logged
shanilr
DW Fresher
*

Reputation: +3/-0
Offline Offline

Posts: 6


View Profile
« Reply #3 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.

Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



© Copyright 2006-2010 DW Forum. All rights reserved

contactSanghala | Cyber Militia | Powered by SMF | SMF © 2006-2009, Simple Machines LLC | Dilber MC Theme by HarzeM