What are Subquery and Co-related Queries in SQL Server ? | SQL Server Interview Questions & Answers

preview_player
Показать описание

In this video we will try to understand what are SQL server sub queries , co-related queries and how they differ from each other.

See our other Step by Step video series below :-
See our other Step by Step video series below :-

-----------------------------------------------------------------------------------------------
For more details :-
📱 Mob. No. : +91-9967590707 / +91 7700975156 / +91-22-49786776

Share, Support, Subscribe and Connect us on!!!

#SQLServer #SQLServerInterviewQuestions #SubqueryinSQL #Subquery&Co-relatedQueries #SQLServerTutorial #SQLServerInterviewQuestions&Answers
Рекомендации по теме
Комментарии
Автор

👊👊👊👊👊👊Smash Subscribe button if you like it.👊👊👊👊👊👊

questpondvideos
Автор

good explanation on sub query and co-related queries, but i think the example given for co-related queries is a terrible solution for finding the second highest salary, this can be much better achieved using a sub query like -> select top 1 .... from (select top 2 ... from order by salary desc) as top2salaries order by salary asc

jzhuo
Автор

Searched from different channels, but at last, you clarified what subquery actually is. Thank You Sir who ever you are❤️

mr.a
Автор

Like a loop withn a loop, Each row of e1 is passed and checked with the condition e2.salary greater than e1.salary and if it satsfies count e2.salary, then outer query conditions that is if is two then execute the outer query and print empname

Subhash_VCU
Автор

Your explanations are very clear sir,
keep up your good work,
may god bless you!!

shobhitsrivastava
Автор

Great and simple explanation with examples. came here after watching a couple of videos that failed to explain this concept so neatly.

arunprashanth
Автор

This is the best explanation I have ever seen.Thank you so much for such elaborated explanation

dipranjan
Автор

THANKs for clear explanation of Co-related Sub-query.

But the query shown for Co-related Sub-query does NOT fetch ANY records when multiple employees have SAME salaries and also gives Incorrect records of Nth Highest salary if multiple employees have SAME salaries in a Table. We can correct the query by adding "DISTINCT" in INNER query.

select *
from emp E1
where 2 =(select Count(DISTINCT E2.salary)
from emp E2
where E2.salary >= E1.salary)

maheshwara.r.
Автор

Your X Highest salary will only worked when there is only one employee having x Highest salary. If there are more then one employee with X highest salary then your query will return no output

subhashkomy
Автор

Your all videos of both channel are just excellent..I wish if all may be free to access

kitchenking
Автор

Thanks...you cleared my this concept 👍👍👍

mahendratawade
Автор

Excellent explanation really helped me

chitrasrinivas
Автор

The difference between both of them is of references ...as in subquery we have no reference or relation between both of inner and outer query but in the latter one we referenced the outer query inside the inner query.

siddharthasharma
Автор

best explanation about Correlated Subqueries

abdulsacur
Автор

OUTSTANDING. You're explanation/demonstration. Well done. I get it. What a big help, thank you, thank you. I finally understand.

cassondrad
Автор

Sir, , a very nice explanation from your side.., sir plz tell me which software you are using for SQL queries, , , and if it is available for free, , send me the link.

unpsir
Автор

Clear, precise and concise, thank you for your time.

searez
Автор

well explain the concept but this will work only if we do not have duplicate salaries, I think you need to use count(distinct(salary))

AbhishekKumarMishra_abhi
Автор

Hi sir
When I am converting Date to integer or decimal using cast and convert, it's reflecting the date value less than its actual value.
Please suggest.

drs
Автор

Thank you so much bro, helped me a lot than my professor or books! Keep it up!

pa