You are teaching joins facts that you never explained why are we using left and right joins great teaching👍
@rathan79429 ай бұрын
😂😂
@arpit98958 ай бұрын
sahii bolee bhaii yaar
@arpit98958 ай бұрын
jo pta he vahi bta rhee
@pratig42842 жыл бұрын
You should explain why you choose left join
@alivia_ansari6 ай бұрын
Watched this video for revision before my interview. Luckily the interviewer asked many questions from SQL and I had to write down the queries. This really helped 😍❤️
@vijaykumar.m35092 жыл бұрын
very thank you madam i cant understand while my madam teaching in class now i can understand
@BobbeeSingh Жыл бұрын
Why a left join for 1st 3 queries and not an inner join? Explaining why left join and inner joins were used would have been helpful.
@snehanair5436 Жыл бұрын
@bobbesingh, inner joins are used to fetch common in both tables, if questions didnt ask connon in both table, insted it just ask partial data ,2 or more data id, if here all data, than inner
@090-jellabharath2 Жыл бұрын
Actually you can use.
@GowthamS-vy9ts9 ай бұрын
@@snehanair5436 if we use left join it also give the bal dept name also right??
@madhukareppalapelly72532 жыл бұрын
in query 2...we have to write dept_id in select statement when we write group by class using dept_id
@rahulbagada7 Жыл бұрын
no bro it is not compulsory
@MrTejasreddy Жыл бұрын
u r explanation is really simple and clear..but if u provied data for practice for beginner then its very helpfull to them ...anyway gud explanation..keep it up...😊
@aryanshinde1822 Жыл бұрын
Mam 3rd query we can use natural join through joining two tables
@sandipwaghmare44772 жыл бұрын
#Thank you shoo much the way of explaining topic is great within a half hour i have learn lot ☺️
@aryanshinde1822 Жыл бұрын
Mam why should be use left join we can also use inner join throught join the 2 or more table
@appianbpmdesigner16732 жыл бұрын
INSTEAD OF USING JOINS, WE CAN ACHEIVE THIS BY SUB QUARIES NAA. SELECT DEPT_NAME FROM DEPT_TB WHERE DEPT_ID IN (SELECT DEPT_ID FROM EMPLOYEE GROUP BY DEPT_ID HAVING COUNT(DEPT_ID)>2)
@shivankitss83962 жыл бұрын
Ayy lol . We have almost similar profiles.
@akshaykumarrai5055 Жыл бұрын
How I will come to know which should be the left column here ? I mean for example you fetched two columns from employees why not from department ?
@beingrishi645010 ай бұрын
Can you share the table schema in description box
@Priyanka-q3k3d4 ай бұрын
In query 3 can we change the order of manager and employee like. Can we write manager first and employee second? Please answer.
@manojkumarrajaka52043 жыл бұрын
I subscribed ur channel without watching this video. Bcz I assume that it will be helpful for me. Tq. And joined in ur telegram group too
@prachikushwaha1082 жыл бұрын
Same me too🤗😂
@aastha4708Ай бұрын
I got all the queries but why and how only left join we have used why not other joins??
@vasugupta42729 ай бұрын
why we use left join not normal join..any specific reason
@user-ej5nt6lk3q2 жыл бұрын
thanks a lot saloni. it was really helpful appreciate the hard work keep going!!!!
@neeshakumarisinha75962 жыл бұрын
For the first question the Having clause seems incorrect. It should be HAVING COUNT(e.emp_id) > 2 to fetch the number of employees greater than 2 from each department.
@vishalchauhan9832 Жыл бұрын
I believe dept_id is totally fine. You are checking count of dept_id . If occurence of any dept_id is more than 2 then we need to print that department name. So it is totally fine
@manishascorner5443Ай бұрын
Yes dear you are totally correct
@nayanmonibaruah60492 жыл бұрын
This is what I wanted 😃
@amalpeters Жыл бұрын
1st query got error like not a group by expressions
@maradadharmaraju2358 Жыл бұрын
Why u chose left join for 1st question why not inner join
@crictune88202 жыл бұрын
The column you taken after group by clause, it should be there in select statement too🙏, I have wasted hour in finding it out as I am beginnet
@CodeEra20202 жыл бұрын
It will work in mysql but if you are using oracle Or any other dbms then you have to write it with select statement also..
@jiteshshewale764 Жыл бұрын
I think this query won't work as we are referening d.dept_name in select statement and grouping by e.dept_id which contradict sql syntax and rule, correct me if i m wrong
@jiteshshewale764 Жыл бұрын
select d.dept_name, count(*) from dept d left join employee e on d.dept_id = e.dept_id group by d.dept_name having count(d.dept_name) > 2; this might be the correct query using joins
@jiteshshewale764 Жыл бұрын
refering 1st query question
@snehalgajbhiye14547 ай бұрын
Thank you so much saloni😊
@rahuljain-zw8vx2 жыл бұрын
how to know when to use left join or inner join
@YardAnalytics2 жыл бұрын
Say you have two tables t1 and t2. Use left join if you need records that are common in both t1 and t2 as well as those records that are unique to t1( considering t1 to be the left side table). And use inner join only if you want just the common records for both the tables t1 and t2. Hope this helps :)
@rneditz32506 ай бұрын
Are this tables are given in our interview rounds while asking query to us????
@ponkarthickkumarl16557 ай бұрын
Can i use full outer join for 1 and 2 questions
@sudhanshupathak7844 Жыл бұрын
In the second one in place of e.dept_id it will come e._dept_name with group by
@athul03 Жыл бұрын
d.dept_name . This is correct. Why the query in the screen works ???
@PandeyJii96323 жыл бұрын
Why to use left join for emp and manager to be from same city. We can simply use Join or Inner join. e.empid= m.magerid will be correct as we shud have emp ID in employee table
@PandeyJii96323 жыл бұрын
U have prepared tables to show no null value....huhh
@talknow28597 ай бұрын
You're amazing 🎉!
@gulistananwar24182 жыл бұрын
Perfect and easy explanation, thankyou!
@CodeEra20202 жыл бұрын
Glad it was helpful!
@swarnadipmukherjee2826 Жыл бұрын
No point of using left join we should use inner join to achieve actual result.
@pranavshelar46902 ай бұрын
Also Make tricky video on subqueries❤
@Priyanka-q3k3d4 ай бұрын
I think there is no need of group by clause in first query
@anjalisharma1351 Жыл бұрын
Didilnt explain left join.. 😢 . Why are we using left join and not right join?.. i got more confused after reading this
@prasannas4398 ай бұрын
How to know the here we use left join here we use right join to know that
@amalpeters Жыл бұрын
First query Answer is below select d.department_name,e.department_id from departments d left join employees e on d.department_id=e.department_id group by e.department_id,d.department_name having count(e.department_id)>2;
@divyadubey66793 ай бұрын
You should y u chhosen left join And one more things ur question should b seen during query.
@AmitKumar-tl2fj11 ай бұрын
Tell us why you used left join
@harshithapogala88454 ай бұрын
Here dept_id means number of employees present in the table is it friends?
@manishascorner5443Ай бұрын
No dear
@sravanthipatil7632 жыл бұрын
(Operand data type varchar is invalid for avg operator) mam can u help me out am getting this error while doing 2qsn query
@sudhanshupathak7844 Жыл бұрын
It shows an error because it's incorrect when you are using a group with any column name you need to use the same with select statement . 2nd solution is wrong
@pranishsonone78392 жыл бұрын
Mam plese chake your Firstt query it is wrong
@rajeshkumar2k567 Жыл бұрын
it would be more benificial , if the data in the tables were provided to practice!
@radhasakhi45463 жыл бұрын
Nice video Didi 😊😊
@CodeEra20203 жыл бұрын
Thank you
@gashok52316 ай бұрын
@@CodeEra2020 table having columns custid,orderid,menuitemid,transactid How to write a query most purchased item?
@bhagirathmakwana91122 жыл бұрын
thank u mam🙏
@wikimarathi Жыл бұрын
Thanks❤
@sridharmurari3007 Жыл бұрын
does inner join give different result ?
@ratneshwarsingh18728 ай бұрын
It gives records which are present in both the tables but left join unlike inner join gives all the records for left table(on condition) as well as records of th corresponding data which is present in the right table, id not present then it return Null corresponding to that particular data
instead of using left join in first query can we use INNER JOIN?
@sanskargupta4702 жыл бұрын
yes you can
@vedantkadam4221 Жыл бұрын
can i get a pdf for table creation steps pls
@mrkaydee02 жыл бұрын
Amazing explanation 😌
@roshankamble3747 Жыл бұрын
you should group by d.dept_name not e.dept_id
@gokulprasandh10012 жыл бұрын
Not working it's shows invalid identifier
@gguk3471 Жыл бұрын
managers also should be employee but in this example ithkink not, its too hard the i understand
@NehaKumari-cx6un2 жыл бұрын
Nice
@AdityaSairam11 Жыл бұрын
I am using postgresql, the query for 1st question is not running fine. Below is the query I used: select d.dept_name from public.department d left join public.emp e on d.dept_id = e.dept_id group by e.dept_id having count(cast(e.dept_id as bigint))>2; Error: SQL Error [42803]: ERROR: column "d.dept_name" must appear in the GROUP BY clause or be used in an aggregate function Position: 8 Error position: line: 79 pos: 7 Solution: select d.dept_name from public.department d left join public.emp e on d.dept_id = e.dept_id group by e.dept_id,d.dept_name having count(cast(e.dept_id as bigint))>2; I had to add d.dept_name in the group by clause. It is working fine now. I know that this video covers only sql join solutions, however alternate approach to solve question #1: select dept_name from department where dept_id in (select dept_id from emp group by dept_id having count(cast(dept_id as bigint))>2);
@vijay_madane037 ай бұрын
Left join kyu use Kiya he samja nhi..
@Entertainment_12331 Жыл бұрын
Plj share data in discription all video
@nishchalbasyal4 ай бұрын
I think your qn 3 answer is mistake either you have to use right join or inner join. SELECT d.dept_name FROM department d Left JOIN employee e ON d.dept_id = e.dept_id GROUP BY d.dept_name HAVING COUNT(e.emp_id) > 2; this will include all department with zero employes
@cr_kumar12843 жыл бұрын
Wildcard character explain plzz
@sivaprasadreddy78792 жыл бұрын
can you please do a videos for subqueries like this simple trick
@Ashis_Kumar. Жыл бұрын
Where is the script to make the table? Do you want me to manually create the tables? Kids these days 🙄
@vamshitha4492 жыл бұрын
Write a query to get particular row from a table in SQL server
@stallerina2 жыл бұрын
Select * from table name where id =4 l;
@gollangianand63782 жыл бұрын
Madam little bit confusion please do some queries or give any pdf for practice
@vikaspatil58072 жыл бұрын
Mam Datediff and DateFormat ke releted video banavo please mam
@Explore_Sarkar_Lens Жыл бұрын
@codeera The First & second answer is not working MS Sql Server. I am attaching the whole query , please correct me If I am wrong and attching the correct query too: create table Manager( Manager_id varchar(30) primary key, Manager_name varchar(30), City varchar(10) ) create table Department( Dept_id int primary key, Dept_name Varchar(10) ) create table employee( emp_id int primary key, emp_name varchar(30), Salary int, city varchar(30), Dept_id int foreign key references Department(Dept_id), Manager_id varchar(30) foreign key references Manager(Manager_id) ) insert into Manager values('M101','Ajay','Pune'); insert into Manager values('M102','Amit','Mumbai'); insert into Manager values('M103','Sandeep','Bangalore'); insert into Manager values('M104','Prabhakar','Pune'); insert into Manager values('M105','Joydeep','Indore'); insert into Manager values('M106','Shubham','Bangalore') select * from Manager insert into Department values(1,'Admin'); insert into Department values(2,'HR'); insert into Department values(3,'Developer'); insert into Department values(4,'Tester'); insert into Department values(5,'Accounts') select * from Department insert into employee values(1,'Karan',300000,'Mumbai',2,'M102'); insert into employee values(2,'Rohit',75000,'Bangalore',1,'M106'); insert into employee values(3,'Ankush',35000,'Ahemdabad',5,'M105'); insert into employee values(4,'Priyanshi',500000,'Kolakata',3,'M102'); insert into employee values(5,'Sanket',100000,'Pune',3,'M101'); insert into employee values(6,'Shruti',80000,'Indore',4,'M105'); insert into employee values(7,'Jayraj',75000,'Bhopal',2,'M103'); insert into employee values(8,'Dilip',66000,'Mumbai',3,'M102'); insert into employee values(9,'Geet',17000,'Mumbai',2,'M101') select * from employee --1st Question select d.Dept_name from Department d left join employee e on d.Dept_id=e.Dept_id group by e.Dept_id having count(e.Dept_id)>2 -- Correct Answer : --1st question select d.Dept_name from Department d join employee e on d.Dept_id=e.Dept_id group by d.Dept_name having count(*)>2 --2nd Question select d.Dept_name, avg(e.Salary) from Department d join employee e on d.Dept_id =e.Dept_id group by d.Dept_name having AVG(e.salary)>75000 order by avg(e.Salary) desc
@akashsrivastava631110 ай бұрын
Hi, there are a few syntax errors try the following create table Manager( Manager_id varchar(30) primary key, Manager_name varchar(30), City varchar(10) ); create table Department( Dept_id int primary key, Dept_name Varchar(10) ); create table employee( emp_id int primary key, emp_name varchar(30), Salary int, city varchar(30), Dept_id int, foreign key (Dept_id) references Department(Dept_id), Manager_id varchar(30), foreign key (Manager_id) references Manager(Manager_id) ); insert into Manager values('M101','Ajay','Pune'),('M102','Amit','Mumbai'), ('M103','Sandeep','Bangalore'), ('M104','Prabhakar','Pune'),('M105','Joydeep','Indore'), ('M106','Shubham','Bangalore'); select * from Manager; insert into Department values(1,'Admin'),(2,'HR'),(3,'Developer'),(4,'Tester'),(5,'Accounts'); select * from Department; insert into employee values(1,'Karan',300000,'Mumbai',2,'M102'), (2,'Rohit',75000,'Bangalore',1,'M106'), (3,'Ankush',35000,'Ahemdabad',5,'M105'), (4,'Priyanshi',500000,'Kolakata',3,'M102'), (5,'Sanket',100000,'Pune',3,'M101'), (6,'Shruti',80000,'Indore',4,'M105'), (7,'Jayraj',75000,'Bhopal',2,'M103'), (8,'Dilip',66000,'Mumbai',3,'M102'), (9,'Geet',17000,'Mumbai',2,'M101'); -- q1 select count(employee.emp_id) t,department.Dept_name from department join employee on department.Dept_id=employee.Dept_id group by department.Dept_name having count(employee.emp_id)>2; -- q2 select avg(employee.salary), department.Dept_name from department join employee on department.Dept_id=employee.Dept_id group by department.Dept_id having avg(employee.Salary)>75000 order by department.Dept_name desc; -- q3 select manager.city, manager.Manager_name, employee.emp_name from manager join employee on manager.Manager_id=employee.Manager_id where manager.city=employee.city; -- q4 select employee.emp_name, employee.Salary, department.Dept_name,manager.Manager_name from employee join department on employee.Dept_id=department.Dept_id join manager on employee.Manager_id=manager.Manager_id where employee.salary between 35000 and 90000;
@manishascorner5443Ай бұрын
The answer of 1st question is not correct the correct answer is as following Select dept_name,count(emp_id) From department Inner join employee On department.dept_id=employee . Dept_id Group by dept_name Having count(emp_id)>2; You can alise if you want 😊
@MamtaVerma-tc5ip3 жыл бұрын
What is the name of your telegram account?
@CodeEra20203 жыл бұрын
Name is CodeEra or You will find the joining link in video Description box
@monke8902 жыл бұрын
QUERY 1 IS WRONG
@CodeEra20202 жыл бұрын
It is working fine..
@Priyanka-q3k3d4 ай бұрын
In query 3 can we change the order of manager and employee like. Can we write manager first and employee second? Please answer.