Wednesday, April 20, 2011

Having Clause vs Where Clause




Difference between having and where clause:

“A query can contain both a WHERE clause and a HAVING clause.” WHERE comes 1st then Having comes if they are in one sql query."

Having clause:
  • Operates on Groups. 
  • used only with the SELECT statement.
  • Is used after GROUP BY clause.

Where clause:


  • Operates on individual rows.
  • Where Clause can be used other than Select statement also.
  •   Where is used before GROUP BY clause




1 comment:

  1. Having clause is used only with group functions whereas Where is not used with.
    for more sql interview question and answer please visit this link.

    ReplyDelete