Our Recommendations :-
Follow IT FB Page

What is the difference between having and where clause?

Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 Uma asked almost 3 years ago

    0       0 Answer Now Comment Report
6 Answers
Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 acharya answered over 2 years ago

The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions.

    0       0 Comment Report
Important Note – Preparing for IT?
CAKART provides Indias top faculty each subject video classes and lectures – online & in Pen Drive/ DVD – at very cost effective rates. Get video classes from CAKART.in. Quality is much better than local tuition, so results are much better.
Watch Sample Video Now by clicking on the link(s) below – 
For any questions Request A Call Back  
Open uri20170510 32134 1ue0f38?1494421710 rohit agarwal answered almost 3 years ago

Where Vs Having / Difference between having and Where clause Basic difference between Sql Where and Having Clause We always get confused between WHERE and Having clause and make mistakes. Here in this article, I will try to highlight all the major differences between WHERE and HAVING, and things you should be aware of, when using either WHERE or HAVING. Most of the time you will get the same result with Where or Having . The below given two SQL command produces the same result set That is, both count the number of records found for the states of California and Los Angles. SELECT state, COUNT(*) FROM Test WHERE state IN ('CA', 'LA') GROUP BY state ORDER BY state SELECT state, COUNT(*) FROM Test GROUP BY state HAVING state IN ('CA', 'LA') ORDER BY state So, where is the difference ,Which is better? I'll let you answer those questions in a minute. The main reason for using WHERE clause is to select rows that are to be included in the query. For example, assume table Test.Suppose I want the names, account numbers, and balance due of all customers from California and Los Angles. Since STATE is one of the fields in the record format, I can use WHERE to select those customers.

    0       0 Comment Report
Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 ifrs answered almost 3 years ago

Basic difference between Sql Where and Having Clause

    0       0 Comment Report
Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 Prity answered almost 3 years ago

What is the difference between having and where clause? Both Having Clause and Where clause is used to filter the data coming from the Select statement, but still there are some differences between them. Though the HAVING clause specifies a condition that is similar to the purpose of a WHERE clause, the two clauses are not interchangeable. Listed below are some differences to help distinguish between the two: 1. The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. 2. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping. 3. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions. for Example: if for an "Select" statement we use the "where" clause then the the result based on the "where" condition results and then we can use "group by" clause to arrange in some order, Now if we want to impose the condition on that group then we use "having" clause. The main reason for using WHERE clause is to select rows that are to be included in the query. For example, assume table Test.Suppose I want the names, account numbers, and balance due of all customers from California and Los Angles. Since STATE is one of the fields in the record format, I can use WHERE to select those customers.

    2       0 Comment Report
Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 CA Sandeep Bohra answered almost 3 years ago

Dear Friend, -HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. -HAVING can be used only with the SELECT statement. -HAVING is typically used in a GROUP BY clause. -HAVING clause is like a WHERE clause, but applies only to groups as a whole. -When GROUP BY is not used, HAVING behaves like a WHERE clause. **Difference** HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause. The WHERE clause is applied first to the individual rows in the tables . Only the rows that meet the conditions in the WHERE clause are grouped. The HAVING clause is then applied to the rows in the result set. Only the groups that meet the HAVING conditions appear in the query output. You can apply a HAVING clause only to columns that also appear in the GROUP BY clause or in an aggregate function

    0       0 Comment Report
Avatar 37a3bd7bc7328f0ead2c0f6f635dddf60615e676e6b4ddf964144012e529de45 lochan answered almost 3 years ago

HAVING is used to specify a condition for a group or an aggregate function used in select statement. The WHERE clause selects before grouping. The HAVING clause selects rows after grouping. Unlike HAVING clause, the WHERE clause cannot contain aggregate functions Thanks

    0       0 Comment Report
Similar Questions
Get Notifications
Videos
Books
Notes
Loading
SIGN UP
Watch best faculty demo video classes

These top faculty video lectures will
help u prepare like nothing else can.