Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 7762 |  Welcome, Guest!   Register  Login
 Home > Forums > Sql Server > Difference between Having and Where.. ...
Muhsinathk

Difference between Having and Where..

Replies: 6 | Posted by: Muhsinathk on 6/12/2012 | Category: Sql Server Forums | Views: 377 | Status: [Member] | Points: 10  


What is the difference between 'Having' and 'Where'?


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Muhsinathk
Muhsinathk  
Posted on: 6/12/2012 12:20:09 AM
Level: Bronze | Status: [Member] | Points: 25

Having used with aggregate function.

SELECT state, COUNT(*)
FROM Test
GROUP BY state
HAVING state IN ('CA', 'LA')
ORDER BY state



WHERE clause is used to impose condition on SELECT statement as well as single row function

SELECT cusnum, lstnam, init
FROM Test
WHERE state IN ('CA', 'LA')

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

CGN007
CGN007  
Posted on: 6/12/2012 2:30:58 AM
Level: Silver | Status: [Member] | Points: 25

Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.
More details follows,
1.http://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/
2.http://www.sql-tutorial.com/sql-having-sql-tutorial/

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Muhsinathk
Muhsinathk  
Posted on: 6/12/2012 2:33:11 AM
Level: Bronze | Status: [Member] | Points: 25

Thank youu

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sriramnandha
Sriramnandha  
Posted on: 6/21/2012 6:29:53 AM
Level: Starter | Status: [Member] | Points: 25

Hi,

Having Clause is Group by Function.

Where condition is used apply conditions in sql query.

Regards

Sriram.R

sriram

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Muralidosscm
Muralidosscm  
Posted on: 7/4/2012 6:17:51 AM
Level: Starter | Status: [Member] | Points: 25

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Perfect.Chourasia@Gmail.Com
Perfect.Chourasia@Gmail.Com  
Posted on: 7/4/2012 6:36:42 AM
Level: Starter | Status: [Member] | Points: 25

http://sandeep-chourasia.blogspot.in/2011/10/diff-bet-having-and-where-clause.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://sandeep-chourasia.blogspot.com/

Muhsinathk, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/18/2013 8:20:17 PM