Difference between Where and Having Clause in SQL | SQL Fundamentals

Difference between Where and Having Clause in SQL | SQL Fundamentals

Ankit Bansal

2 года назад

79,592 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@pratik5648
@pratik5648 - 26.01.2024 14:24

Well Explained :)

Ответить
@equiwave80
@equiwave80 - 07.12.2023 06:01

Hi Ankit,

This playlist is useful to level up on SQL skills. I have started with this "SQL Tips and Tricks" playlist and will move on to the other useful playlists.
A very clear and concise manner of explaining the important difference between the WHERE and the HAVING clause.
Thanks for all your efforts!!! 👍

Regards,
Deepak.

Ответить
@nikhilsk2026
@nikhilsk2026 - 06.11.2023 20:34

great

Ответить
@abhisheksinghchauhan1131
@abhisheksinghchauhan1131 - 14.10.2023 00:17

Both are used to filter the records.
This is the similarity in these.
WHERE is used before aggregation and having is used after aggregation.

HAVING CLAUSE is used only when there is an aggregation and group by.

Where clause can be used without aggregation.

Ответить
@AlbouryNdiaye-ro8qz
@AlbouryNdiaye-ro8qz - 18.09.2023 20:50

Hi Ankit - Clear and to the point as usual. Thank you so much for sharing your knowledge!

Ответить
@reddeppareddy4545
@reddeppareddy4545 - 03.08.2023 05:56

The Having Clause will be used with the filtered value, But the question was , find the average salaries of departments > 10000, Then for AVG we have to consider all the values in each department, Am i right?

Ответить
@shubham_shri_ping908
@shubham_shri_ping908 - 11.07.2023 22:13

Last query is not clear..where should not be used with aggregated function i.e (avg) but u used it sir ?why

Ответить
@ManikandanRaju
@ManikandanRaju - 19.04.2023 21:13

Clear and concise. Thank you for the video

Ответить
@mns5885
@mns5885 - 03.04.2023 21:44

Thanks for the information sir 😊

Ответить
@sannigupta4042
@sannigupta4042 - 24.01.2023 12:53

create table employees
(emp_id int,
emp_name varchar(100),
department_id int,
salary int,
manager_id int);

insert into employees
values
(1,'Ankit',100,10000,4),
(2,'Mohit',100,15000,5),
(3,'Vikas',100,10000,4),
(4,'Rohit',100,5000,2),
(5,'Mudit',200,12000,6),
(6,'Agam',200,12000,2),
(7,'Sanjay',200,9000,2),
(8,'Ashish',200,5000,2)

Please find the DDL for this tutorial. Thanks.

Ответить
@muhammadaqib5882
@muhammadaqib5882 - 06.01.2023 12:52

hello, where can I download this dataset? to practice the sql?

Ответить
@waytosoakshya1127
@waytosoakshya1127 - 04.01.2023 07:21

The tutorial is easy to understand. Only if you could raise the volume of your voice. It's hard to hear clearly

Ответить
@md.sarfarazhussain4144
@md.sarfarazhussain4144 - 26.12.2022 09:59

For self practise, which software should we install in our laptop or any online complier should we use

Ответить
@kundankumar45
@kundankumar45 - 25.12.2022 20:25

HI Ankit can u plz share the datasets

Ответить
@thinkandthink6879
@thinkandthink6879 - 15.12.2022 07:55

Hello sir i have doubt can you please suggest in which order should i follow your playlist i am complete beginner in sql

Ответить
@rakeshgopidi4066
@rakeshgopidi4066 - 30.11.2022 01:03

## Difference between WHERE and Having - interview point of view notes
==> WHERE clause cannot be used with aggregates where as HAVING can. This means WHERE clause is used for filtering individual rows where as HAVING clause is used to filter groups.
==> WHERE comes before GROUP BY. This means WHERE clause filters rows before aggregate calculations are performed. HAVING comes after GROUP BY. This means HAVING clause filters rows after aggregate calculations are performed. So from a performance standpoint, HAVING is slower than WHERE and should be avoided when possible.
==> WHERE and HAVING can be used together in a SELECT query. In this case WHERE clause is applied first to filter individual rows. The rows are then grouped and aggregate calculations are performed, and then the HAVING clause filters the groups.
==> So from a performance standpoint, HAVING is slower than WHERE and should be avoided when possible.
==> Another difference is WHERE comes before GROUP BY and HAVING comes after GROUP BY.

Ответить
@Moon_Rise6393
@Moon_Rise6393 - 19.10.2022 20:21

Thanks ankit

Ответить
@brindhaganesan3580
@brindhaganesan3580 - 12.10.2022 03:37

Good one. It’s clear 😊

Ответить
@datascienceenthusiast3964
@datascienceenthusiast3964 - 14.09.2022 10:45

No doubt its adding value to all SQL beginners .

Ответить
@abonthego
@abonthego - 10.09.2022 20:22

How avg salary in first query was 10000 and in second it came 15000 for dept_id 100?

Ответить
@asif_786
@asif_786 - 30.08.2022 16:56

can you plz make intermediate or advance video course plz
your explanition is great

Ответить
@riyatiwari7178
@riyatiwari7178 - 03.08.2022 20:14

Thank you Ankit for breaking down the difference very clearly and easily. Looking forward to learn more. :)

Ответить
@kumarr3390
@kumarr3390 - 27.07.2022 09:32

Thanks for the video. very informative. Could you please provide datasets used in the videos.

Ответить
@modimansii
@modimansii - 26.07.2022 18:37

Basic but important concept nicely explained.

Ответить
@thedatakid1270
@thedatakid1270 - 08.07.2022 20:45

It's informative

Ответить
@mustafakamal5945
@mustafakamal5945 - 05.07.2022 06:34

Great explanation!

Ответить
@kartikbadal888
@kartikbadal888 - 01.07.2022 15:10

Awesome explanation Ankit

Ответить
@shivarajhalageri2513
@shivarajhalageri2513 - 20.06.2022 21:50

🙌🙌

Ответить
@sourceforaspirants5588
@sourceforaspirants5588 - 06.06.2022 07:27

Awesome 👌

Ответить
@amritasharma276
@amritasharma276 - 25.05.2022 21:55

Sir date-time function related concepts please also Paytm interview questions related to sql. Cross join and especially subquries. I'm getting stuck in subqueries.

Ответить
@sakshamgupta5703
@sakshamgupta5703 - 19.05.2022 14:32

Concept clear in simplest way .

Ответить
@yashsoni2113
@yashsoni2113 - 18.05.2022 05:09

Ankit your videos are very helpful and very easy to understand.
but please also provide the table data so that we can practice and can also save the query for revision in future.
please

Ответить
@yashdhas8202
@yashdhas8202 - 01.05.2022 15:34

Thank you.
You are clearing concepts in most easiest way.

Ответить
@JustinVTom
@JustinVTom - 04.03.2022 06:50

Really helpful. Thanks much buddy 👍👍

Ответить
@shikhasharma328
@shikhasharma328 - 03.03.2022 21:10

Order of commands also matters we can never use having before where.

Because in the backend order of execution goes as below:

Query Process Steps
1. Getting Data (From, Join)
2. Row Filter (Where)
3. Grouping (Group by)
4. Group Filter (Having)
5. Return Expressions (Select)
6. Order & Paging (Order by & Limit / Offset)

Ответить
@muhammedhashir8157
@muhammedhashir8157 - 16.02.2022 15:11

Thanks Ankit!
Key Takeaways
Where - to filter records - checks record/rowwise
Having - to filter on top of aggregation
If both are used where will get executed before having.

Ответить
@florincopaci6821
@florincopaci6821 - 13.02.2022 14:34

All your videous are very useful! Keep going! Thank you!

Ответить
@pavitrashailaja850
@pavitrashailaja850 - 13.02.2022 07:49

👍

Ответить