HAVING CLAUSE and a WHERE CLAUSE

Discussion in 'Databases' started by bgjyd834, Mar 31, 2011.

  1. #1
    What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
    Thanks in advance
     
    bgjyd834, Mar 31, 2011 IP
  2. randheer

    randheer Greenhorn

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    Having clause is used with group by clause. Group by generally used for aggregate function so having is used to filter the data based on aggregate functions.
    While where can used for any general filter condition in query.
    For example
    There is a productorder table now we want the orders in which 3 or more products are ordered.
    Select order, count(product)
    From
    Productorder
    Group by order
    Having count (product) > 3
    It is not possible through where clause.
     
    randheer, Apr 4, 2011 IP
  3. sd3189541

    sd3189541 Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot for this help with example.
     
    sd3189541, Apr 6, 2011 IP