C++ || STL || standard template libraries

Image
                                       C++ STL  1.      Pair :  Syntax :      pair <int,char> p1;     it creates a pair {2,'c'} like this.           pair <int,int> p2;     it creates a pair {2,3} like this .  Basic Code :  #include <bits/stdc++.h> using namespace std; int main() {     // cout<<"hello world\n";     pair <int,int> p1 = {1,2};     cout<<p1.first<< " "<< p1.second<<endl;          pair <int, pair<int ,char>> p2 = {1,{2,'c'}};     cout<<p2.first<<" "<<p2.second.first<<" "<<p2.second.second<<endl;          pair <int,int> arr[] = {{2,3},{4,5},{6,7}};     cout...

1978. Employees Whose Manager Left the Company || Leetcode SQL solution || simple sql query || 🔥🔥🔥💯💯💯✅✅✅

 

Employees whose manages left their company : 👇👇👇💯 




Leetcode Solution:-- 

Intuition

To find the manager who left the company, whose salary is less than 30000 dollars

Approach

step 1: filter the rows whose salary is strictly less than $30000

select *
from employees
where salary <= 30000

 Here manager_id = 6 left the company (because it isn't in employee_id column)

step 2: we need to find the manager how left the company. This we can find by searching it in employee_id from employees table (with a sub query ).

select employee_id  
from employees 
where salary <= 30000 
and manager_id not in (select employee_id from employees)

step 3: we need to order the table by employee_id.


Code

# Write your MySQL query statement below
select employee_id  
from employees 
where salary <= 30000 and manager_id not in (select employee_id from employees)
order by employee_id;






Please go through my blog and find more solutions :- )) 


Happy Learning :-)











Comments

Popular posts from this blog

1050. Actors and Directors Who Cooperated At Least Three Times || Leetcode sql solution || Simple and Easy Approach || ✅✅✅✅💯💯💯🔥🔥🔥🔥

Power of Millets || Happy And Healthy Life

Typing Lesson PART-3