SQL Question in AMAZON - DATA Engineer INTERVIEW🔥! Solution EXPLAINED ❤️

  Рет қаралды 56,240

E-Learning Bridge

E-Learning Bridge

Күн бұрын

Пікірлер: 149
@shashank_mishra
@shashank_mishra 2 жыл бұрын
If you are able to understand the hints for Approach-3 and solve it completely ... I will pin your comment 💯 Also Book Free Trial Now For Job Guaranteed Course - Link in description.
@jagatkrishna1543
@jagatkrishna1543 2 жыл бұрын
YES
@Energybooster111
@Energybooster111 2 жыл бұрын
Sir please make video on Pivot function in Oracle...
@datawarrior1482
@datawarrior1482 2 жыл бұрын
recursive cte should have been used coz soln cannot scale to n level easily
@vinayak6685
@vinayak6685 2 жыл бұрын
Please see my solution and give feedback as I am new to SQL: select A,B from ( select *,row_number() over (partition by sum order by NULL) as rank from ( select *,(a+b) as sum from number_pairs ) ) where rank = 1
@anshumansrivastava2801
@anshumansrivastava2801 2 жыл бұрын
Here is my approach, with cte1 as ( select * from number_pairs where b>a) select * from number_pairs np1 where not exists (select 1 from number_pairs np2 where np1.a=np2.b) union select * from cte1; 3rd approach:- select temp.a,temp.b from( select *,row_number() over(partition by (a+b),abs(a-b) order by a,b ) rn from number_pairs)temp where rn=1;
@rakeshpanigrahi577
@rakeshpanigrahi577 2 жыл бұрын
Hi Shashank, please create a youtube playlist for these types of SQL query solving videos, thank you for all the efforts you are putting in order to make us proficient in Data Area.
@balaji8645
@balaji8645 2 жыл бұрын
Approach C: The following works for even several duplicates and reverses.. Select a,b from (Select a,b,row_number over (partition by c order by a) as rnum from (Select a,b,case when a
@FootballWithAnkit
@FootballWithAnkit 2 жыл бұрын
Great question. Curious to see other sol in video. My sol is below- select min(A), max(B) from number_pairs group by A+B,abs(A-B) order by min(A) asc ;
@s.abinash
@s.abinash Жыл бұрын
Please tell abs
@madireteja7859
@madireteja7859 Жыл бұрын
@@s.abinash it returns absolute value example(1-2=1)instead of -1 it gives 1
@BismarckWangkhem
@BismarckWangkhem 2 жыл бұрын
Hi, thanks for sharing :) here is my approach: with cte as (select t.* ,row_number() over (partition by mul order by a) n from (select *, a*b mul from number_pairs)t) select a, b from cte where n = 1;
@datawarrior1482
@datawarrior1482 2 жыл бұрын
with c1 as ( select a,b , case when ab then a else b end as scol from number_pairs) select fcol,scol from c1 group by fcol,scol
@infinity5503
@infinity5503 2 жыл бұрын
This will reverse distinct pair as well
@datawarrior1482
@datawarrior1482 2 жыл бұрын
@@infinity5503 you can flip it again but core idea is i m not using windows function deliberately ;with c1 as ( select a,b , case when ab then a else b end as scol from number_pairs ), c2 as ( select fcol ,scol from c1 group by fcol,scol ) --distinct reverse pair if changed will be null in the join so flip back select case when a is null then c2.scol else c2.fcol end as ffcol ,case when b is null then c2.fcol else c2.scol end as sscol from c2 left join c1 on c1.a=c2.fcol and c1.B=c2.scol
@gagansingh3481
@gagansingh3481 2 жыл бұрын
It will reverse the order & grouping will get the answer but any other way as using window function with A + b if pair 5,5 and 7,3 and you filter with rownun = 1 then onle of the option 7,3 = 10 , 5+5 = 10 turns the query wrong
@makarsh29
@makarsh29 14 күн бұрын
with cte as ( select *, (A+B) as total , row_number() over(partition by (A+B) order by (A+B)) as rn from number_pairs) select A,B from cte where rn=1; easy .................
@ssaaurabh456
@ssaaurabh456 Жыл бұрын
select A,B from( select *, dense_RANK() over (partition by A+b order by A) as rnk from number_pairs ) A where rnk=1
@b_rizzle4808
@b_rizzle4808 2 жыл бұрын
my approach (group and row_number on the partition of the group): with cte1 as( select a, b , case when a>b then a||b else b||a end as grouping from number_pairs) ,cte2 as( select a,b, grouping , row_number() over(partition by grouping order by a) row_num from cte1) select a,b from cte2 where row_num = 1
@ayushdixit2333
@ayushdixit2333 2 жыл бұрын
with CTE AS( SELECT A,B ,row_number() OVER(Partition By A+B,A*B ORDER BY A) as rn FROM number_pairs) Select * from CTE where rn=1;
@vaibhavverma1340
@vaibhavverma1340 2 жыл бұрын
why do you used a*b ? we can get the result by using a+b .. please tell me sir is there any specefic reason?
@its_neeraj_goyal
@its_neeraj_goyal 2 жыл бұрын
@@vaibhavverma1340 a+b & a*b, Using both you get unique solution pair. Example : 4,8.....8,4......2,16.....16,2 all give same product. Similarly, 1+4=3+2=2+3=4+1=5+0=0+5. All give sum 5 . So either one of condition won't work individually
@rupamkarmakar2315
@rupamkarmakar2315 2 жыл бұрын
Hi, I did this looks like it also worked - with t1 as (select * from number_pairs n1 where (a,b) in (select b,a from number_pairs n2)), t2 as (select * from number_pairs n1 where (a,b) not in (select b,a from number_pairs n2)) select * from t1 where a
@kritikalai8204
@kritikalai8204 2 жыл бұрын
This is my approach.. hope this is what you were expecting: SELECT D.A, D.B FROM (SELECT A, B, ROW_NUMBER() OVER(PARTITION BY (A+B)) row_num FROM numbers) D WHERE D.row_num = 1 OR D.A
@Quenchedfooty
@Quenchedfooty Жыл бұрын
Sums and products can vary right. I can express a sum or product in n nunber of pairs. 10 =8+2=6+4=3+7..... You would lose genuine rows.
@sobhiksaha7140
@sobhiksaha7140 Жыл бұрын
Thanks for the Problem.. Approach 3: select A,B from ( SELECT *, dense_rank() over (partition by a*b order by A) AS prod_rnk FROM PAIRS) a where prod_rnk = 1;
@DilipKumar-of3jk
@DilipKumar-of3jk Жыл бұрын
Thanks for the video!! Another solution: SELECT A,B FROM ( select A,B, ROW_NUMBER() OVER (PARTITION BY CASE WHEN A
@boyinanagendrababu7860
@boyinanagendrababu7860 Жыл бұрын
Select a,b from( select a,b row_number()over(partition by a+b order by 1)rn from table_name ) where rn=1; Dear friends, since here a & b columns are number data types, the above query will help us to get the requested output. Try this one once, thank you
@KDinesh38
@KDinesh38 2 жыл бұрын
Third solution using common key and sorting: Select a,b from ( select *,rank() over (order by case when a
@dreams1ist
@dreams1ist 5 ай бұрын
My approach: with cte as( select *, lead(A) over (order by B) as next_value from number_pairs) select A, B from cte where B!=next_value or next_value is null;
@chandramurugesan6517
@chandramurugesan6517 2 жыл бұрын
Nice explanation. Oracle This query works: select t1.* from t1 --non reverse pairs where (t1.A,t1.B) not in ( select t1.A,t1.B from t1 JOIN t1 t2 ON (t1.A = t2.B and t1.B = t2.A) ) UNION select t1.A,t1.B ---- reverse pairs from t1 JOIN t1 t2 ON (t1.A = t2.B and t1.B = t2.A) where t1.A
@VISHALSINGH-jw2nn
@VISHALSINGH-jw2nn Жыл бұрын
simple case of self join: with cte as(select *,row_number() over( order by (select null)) as r1 from number_pairs) ,cte1 as(select a.A,a.B,a.r1 as r2 from cte a join cte b on a.A = b.B and a.B=b.A and a.r1
@venuch3012
@venuch3012 Жыл бұрын
create table #temp(ID1 int, ID2 int) Insert into #temp values( 1,2) ,(3,4) ,(2,5) ,(5,6) ,(4,3) ,(2,1) select t.ID1,t.ID2,tt.id1,tt.id2 from #temp t inner join #temp tt on t.ID1=tt.ID2 where (t.ID2tt.ID1)
@saisushanthdurvasulabitsian
@saisushanthdurvasulabitsian 2 жыл бұрын
Hi Shashank, thank you so much for sharing such sql questions with us , really helpful, here is my take on the approach-3: i am hashing each a,b combination as 'val1->val2' where val1 = max(a,b) and val2 = min(a,b) and calling it common_key and storing this result into a cte , Ex: 1,2 will have hashed as 2>1 and 2,1 will have hashed as 2->1 and 5,6 will have hashed as 6->5 now using this cte and grouping by common_key, we can eliminate the reverse pairs (as they would hash to same value) by grouping by common key and i am selecting the min(a,b) as a and max(a,b) as b so that only one combination of a,b that hash to same value are picked with cte(a,b,common_key) as (select a , b , case when a < b then concat(b,'->', a) else concat(a,'->', b) end as "common_key" from number_pairs ) select min(a) , max(b) from cte group by common_key; we can also get same result by just selecting a,b instead of min(a),min(b) because using group by without aggregation will act like distinct with cte(a,b,common_key) as (select a , b , case when a < b then concat(b,'->', a) else concat(a,'->', b) end as "common_key" from number_pairs ) select a , b from cte group by common_key; please review and let me know your thoughts , thanks
@omeshagrawal9959
@omeshagrawal9959 2 жыл бұрын
with helper_table as ( select A,B, concat(A,B) as curr,concat(B,A) as rev,A-B as difference from Temp) select distinct A,B from helper_table where curr not in (select rev from helper_table) or curr in (select curr from helper_table where difference>=0); works with duplicates as well as A and B having same values
@eldragonrv
@eldragonrv Жыл бұрын
The correct answer for approach-3 is using ntile(2). Using row_number() will not give correct answer for those pairs having reversed values in the table where sum will be same like (1,7) (2,6) (3,5). Here's the query : select A,B from ( select *, ntile(2) over (partition by SUMM order by A asc) as RANKS from ( select *, A+B as SUMM from number_pairs ) ) where RANKS == 1
@ravisharma3069
@ravisharma3069 2 жыл бұрын
select a,b from number_pairs group by a+b; i tried using window function and got output but then i checked everyone is using window function but not got pinned then again i went through our hint and the best hint was dont think too much complex stick with your basic and you will get you result.
@bharatchaudhury
@bharatchaudhury 6 ай бұрын
Aproach C : with cte as ( Select * , case when A < B then concat(A,B) else concat(B,A) end as pairs from number_pairs ) Select A, B from (Select * , row_number() over(partition by pairs) as rn from cte )X where rn = 1
@skarthikamca
@skarthikamca 2 жыл бұрын
How about this easy method?? 1. Swapping 2. Distinct 1. Swapping is like Case when aa then b else a end as B 2. apply the distinct on top of this
@vishwajeetbehera9822
@vishwajeetbehera9822 4 ай бұрын
Select n1.a,n1.b from number_pairs n1 left join number_pairs n2 on n1.a=n2.b group by n1.a,n1.b having count(n1.a) = 1; This is join approach i tried where we are joining with left join so all the pairs having duplicate will have count more than 1 so later we can filter count more than 2
@harxhdeepsingh
@harxhdeepsingh Жыл бұрын
Approach 4: Add a column named a+b and another named abs(a-b) and and then choose distinct over these two columns
@ramchavali5825
@ramchavali5825 Жыл бұрын
Great explanation on the usage of Exists, select min(a), max(b) from (select a, b, case when a < b then a||'_'||b else b||'_'||a end as concat_ab from number_pairs) t1 group by concat_ab
@akshatjain2315
@akshatjain2315 Жыл бұрын
with cte as ( select *, row_number() over () as no from table ) select table.A,table.B from table except select x.A,x.B from cte as x join cte as y on x.A=y.B and x.B=y.A and x.no < y.no union select x.A,x.B from cte as x join cte as y on x.A=y.B and x.B=y.A and x.no > y.no
@lipuleon2796
@lipuleon2796 2 жыл бұрын
just one line select a,b from (select rowid,rank() over (partition by greatest(a,b) , least(a,b) order by a,b) k,a,b from number_pairs) where k=1
@KoushikT
@KoushikT 2 жыл бұрын
My Approach 3 with cte as ( select A,B,A+B, row_number()over (partition by A+B order by A) as rno from number_pairs ) select * from cte where rno=1
@shaloomathew3628
@shaloomathew3628 Жыл бұрын
with cte as ( select A,B , row_number over(partition by key_value order by A) rnk from (select A,B,A*B as key_value) ) Select A,B from cte where rnk = 1;
@janaktyagi2720
@janaktyagi2720 2 жыл бұрын
Hi Shashank, my sql solution with demo as (select A,B, case when A>B then Concat(A,B) else Concat(B,A) end as id from number_pairs) , demo2 as (select *,ROW_NUMBER() over (partition by id order by id) as row_count from demo) select A,B from demo2 where row_count= 1
@rakeshchaudhary8255
@rakeshchaudhary8255 Жыл бұрын
My Attempt: with ranked_table as ( select *,dense_rank() over (partition by a*b order by A) rnk from number_pairs) select A,B from ranked_table where rnk=1;
@shashankemani1609
@shashankemani1609 2 жыл бұрын
looks simple yet complex to solve. Thanks for explaining!
@SudhirKumar-rl4wt
@SudhirKumar-rl4wt 2 жыл бұрын
with temp as ( select a,b,row_number() over(partition by a*b,a+b order by a) rnk from tab1 ) select a,b from temp where rnk=1
@iamgauravnagar
@iamgauravnagar 2 жыл бұрын
Thank you Shashank for great questions and providing detail answer!! Here is my answer for 3rd Approach Select A, B FROM ( Select A,B,row_number() over(partition by id order by id) rn from (Select A,B,A+B as id from number_pairs ) temp1 ) temp Where rn=1 Output A B 1 2 3 2 2 4 5 6
@infinity5503
@infinity5503 2 жыл бұрын
Will it work with pairs likes 3,7 and 5,5 sum is 10
@krishnachaitanyareddy2781
@krishnachaitanyareddy2781 Жыл бұрын
@@infinity5503 I got same doubt
@ajaydhanwani4571
@ajaydhanwani4571 2 жыл бұрын
Even I got similar question in interview, instead of numbers i got location like if pune to kolkata exists then eliminate kolkata to pune
@ananthram8062
@ananthram8062 Жыл бұрын
WITH CTE AS ( select *,(case when AB then A ELSE B END) AS B1 from number_pairs ) SELECT A1,B1 FROM CTE GROUP BY A1,B1
@MAYANKBHARTI26
@MAYANKBHARTI26 2 жыл бұрын
create table number_pairs (A int, B int); insert into number_pairs values (1,2),(3,2),(2,4),(2,1),(5,6),(4,2); select p1.A,p1.B from number_pairs p1 left join number_pairs p2 on p1.B=p2.A and p1.A=p2.B where p1.A
@sathurmukil6308
@sathurmukil6308 6 ай бұрын
WITH tab as ( SELECT greatest(a,b) a,least(a,b) b,row_number() OVER (partition by greatest(a,b),least(a,b) order by greatest(a,b),least(a,b)) rnk from numeric_data ) select a,b from tab where tab.rnk = 1;
@AkshayDabhade-q6r
@AkshayDabhade-q6r 6 ай бұрын
@E-learning Bridge with tb1 as (select A,B,ROW_NUMBER() over(partition by A+B order by A) as rn2 from number_pairs) select A,B from tb1 where rn2=1 This query is also working perfectly fine, is this a right approach ?
@AmitSingh-ut4wt
@AmitSingh-ut4wt Жыл бұрын
WITH CTE AS (SELECT CASE WHEN A>B THEN B ELSE A END A, CASE WHEN B>A THEN B ELSE A END B FROM number_pairs) SELECT DISTINCT A, B FROM CTE;
@KisaanTuber
@KisaanTuber 2 жыл бұрын
My solution: with T1 AS (select row_number() over(order by A) as row_id, * from number_pairs), T2 as (select * , case when tab2.row_id > tab1.row_id then 1 when tab2.row_id is null then 1 else 0 end as include_flag from T1 tab1 left join T1 tab2 on tab1.B = tab2.A and tab1.A = tab2.B) select A , B from T2 where include_flag = 1;
@dhirajkumarsahu999
@dhirajkumarsahu999 2 жыл бұрын
Hi Shashank, thanks for the Video, here is my approach in mysql-- select A, B from number_pairs where (A>B and (B,A) not in (select A, B from number_pairs)) or B>=A;
@PraveenKumar-pd9sx
@PraveenKumar-pd9sx 11 ай бұрын
Select A, B from number_pairs where (A,B) NOT IN ( SELECT B AS 'A', A AS 'B' FROM number_pairs)
@saikatde6343
@saikatde6343 2 жыл бұрын
Hi Shashank , can you please check the solution? with cte as ( select * , case when B>A then A else B end as p1, case when B
@artigupta4300
@artigupta4300 2 жыл бұрын
Using union we can have this output. Just : select a, b from t1 union select b, a from t2:
@VinayKumar-st9iq
@VinayKumar-st9iq Жыл бұрын
Approach -4 : Use Distinct and Case Boom 💥 Select Distinct Case When A
@mruthyunjayprasad9578
@mruthyunjayprasad9578 2 жыл бұрын
select A,B from ( select *,row_number() over( partition by sum order by SUM) row_num from (select*,(A+B) AS SUM from number_pairs ) T2 ) T3 where row_num = 1
@ranit9841
@ranit9841 2 жыл бұрын
Answer to 3rd approach: Select a, b from (Select a, b, row_number() over(partition by ab order by a) as rown from (Select a, b, concat_ws(", ", sort(array(a, b))) as ab from tableName) t) t1 Where rown = 1
@albinchandy6056
@albinchandy6056 Жыл бұрын
select A,B from number_pairs t1 where (A,B) not in (select B,A from number_pairs t2 where t1.A>t2.A) ;
@abhisheksaxena2211
@abhisheksaxena2211 2 жыл бұрын
Thanks for sharing your knowledge with us :) Here's my solution with approach 3 with cte as ( select a.number1,a.number2, row_number()over (partition by number1+number2 order by number1) as rownumber from #test a ) select number1,number2 from cte where rownumber=1
@himanshujain2047
@himanshujain2047 2 жыл бұрын
This will create single partition for all records which will give the same sum like- 1,4 and 2,3 will give 5 and this query will remove 2,3 from the result set and thus will remove valid records as well.
@abhisheksaxena2211
@abhisheksaxena2211 2 жыл бұрын
@@himanshujain2047 Thanks for your reply. I try to update solution
@abhisheksaxena2211
@abhisheksaxena2211 2 жыл бұрын
Here is the updated solution: For Approach 3: with cte as ( select a.number1,a.number2, row_number()over (partition by number1+number2,number1*number2 order by number1) as rownumber from #test a ) select number1,number2 from cte where rownumber=1
@infinity5503
@infinity5503 2 жыл бұрын
Solution using partition : select a,b from (select a,b,row_number() over (partition by min(a,b),max(a,b)) rn from numbers ) where rn = 1; min(a,b),max(a,b) - will serve as key Like for pair 1,2 and 2,1 Key = 1,2 Shashank sir plz post more questions like this it helps a lot
@VedanttMehtaa
@VedanttMehtaa 2 жыл бұрын
my Solution: with cte as( select l.A as leftA, l.B as leftB,coalesce(r.A,l.A) as rightA,coalesce(r.B,l.B) as rightB from number_pairs l left join number_pairs r on l.B=r.A ) , f_table as ( select leftA as A, leftB as B from cte where leftA != rightB ), row_num_cte as ( select A,B ,row_number() over(partition by A,B order by A) as rn from f_table ) select A,B from row_num_cte where rn
@rishav144
@rishav144 2 жыл бұрын
need more such SQL videos
@manishdabas5809
@manishdabas5809 2 жыл бұрын
Select * from (select p.* , row_number() OVER( partition by A+B, case when A>B then A-B else B-A end order by A )rn from number_pairs p)Z where Z.rn=1
@rajeshawasthi3727
@rajeshawasthi3727 2 жыл бұрын
SELECT A,B FROM ( SELECT A,B,ROW_NUMBER() OVER (PARTITION BY A+B ORDER BY A+B) Rnk FROM number_pairs )RS WHERE RS.Rnk=1
@rajdeepchakraborty7031
@rajdeepchakraborty7031 2 жыл бұрын
select A, B from number_pairs where (B-A) != -1 and -2 it also give result
@sachurv7822
@sachurv7822 2 жыл бұрын
Damn genius. yet simple still mastermind
@gagansingh3481
@gagansingh3481 2 жыл бұрын
It remove 3,2 pair which is needed wrong query
@rajdeepchakraborty7031
@rajdeepchakraborty7031 2 жыл бұрын
@@gagansingh3481 it's written random over there
@shubhamsharma-ne2ke
@shubhamsharma-ne2ke 2 жыл бұрын
WITH src AS ( SELECT CASE WHEN A < B THEN A ELSE B END AS num1, CASE WHEN A > B THEN A ELSE B END AS num2 FROM number_pairs ), final_data AS ( SELECT num1, num2, ROW_NUMBER() OVER (PARTITION BY num1, num2 ORDER BY (SELECT NULL)) AS rn FROM src ) SELECT num1, num2 FROM final_data WHERE rn = 1
@gagansingh3481
@gagansingh3481 2 жыл бұрын
select A1 AS A,b1 AS B FROM ( sELECT * , CASE WHEN A < B THEN A ELSE B END AS A1, CASE WHEN A>B THEN a ELSE b end AS B1 from number_pairs ) AS T1 group by A1,B1
@Project-e5u
@Project-e5u Жыл бұрын
Select a,b From number_pairs group by (a+b)
@rockykefunday2707
@rockykefunday2707 2 жыл бұрын
select * from table minus select * from table where a>b
@SANJAYYADAV-hm2bs
@SANJAYYADAV-hm2bs 7 ай бұрын
please upload more such(good level) interview question related to product based companies.
@porshiabanik9361
@porshiabanik9361 Жыл бұрын
Here is my approach: WITH REVERSED_PAIRS AS (SELECT A,B, ROW_NUMBER()OVER(ORDER BY A) AS ROW_NUM FROM number_pairs WHERE A>B), ORDERED_PAIRS AS (SELECT A,B FROM number_pairs WHERE A
@dishitaneve8362
@dishitaneve8362 2 жыл бұрын
I saw your channel focuses on data field. Please make more video for data science. Freshers
@realcontent2008
@realcontent2008 2 жыл бұрын
3 approach all about partition by and row number
@mihirbhagat54
@mihirbhagat54 2 жыл бұрын
Hi Shashank, I have a question in mind, what if the value of A, B are same then how will the greater than condition work?? Please, can u elaborate the condition for that situation? I don't know if it is possible or not.
@debabratabar2008
@debabratabar2008 2 жыл бұрын
hi shashank , i have tried one new approach , can you please check query ---> select id1,id2 from (select id1,id2 , (id1+id2 ) as total from table1 ) as table2 group by table2.total i have taken two column id1 and id2 instead A,B please tell me , is this solution correct ?
@rockstar-sg2tz
@rockstar-sg2tz 2 жыл бұрын
Tried using not in : SELECT A,B from newList where (A,B) NOT IN(SELECT B,A FROM newList where B>A);
@otmanmssaddar5885
@otmanmssaddar5885 2 жыл бұрын
very new to sql, for the 3rd approach we coukd sort using DISTINCT operator. SELECT DISTINCT(A,B) FROM table; What do you think ?
@aayushsingla3034
@aayushsingla3034 2 жыл бұрын
Can you please make more videos or a playlist like this in which you will provide good questions along with their solutions for placement in the good company. Thank you!
@sandeepanpaul2653
@sandeepanpaul2653 2 жыл бұрын
It would be great if you could put up a drive link of the most asked interview questions for DE. Amazing content as always, thanks
@rose9466
@rose9466 Жыл бұрын
Hy Shashank, please make more of SQL videos and also if you could make Python questions too
@rohitsatpute2209
@rohitsatpute2209 2 жыл бұрын
Bhai please data analyst and scientist ke interview questions ka video bnao na for fresher, entry-level, mid senior level ke liye
@shahinurrahman7745
@shahinurrahman7745 2 жыл бұрын
Thanks for these amazing videos Shashank. One request, can you please make a video on system design for DE? Like what are the main topics asked in DE system design interviews at mid levels (7-8 YOE)
@shashank_mishra
@shashank_mishra 2 жыл бұрын
Sure Noted
@chaitanyapanchal1312
@chaitanyapanchal1312 2 жыл бұрын
Hi Shashank, My Approach is: If we have to find the pair value of A and B having 2,1 or 1,2. Then as we can see if we have required pair then sum of A+B or B+A will be equal. Therefore we can right require below: select A,B,A+B as total from number_pairs group by total having count(total)>1 Please Correct me if I am wrong.
@strong8515
@strong8515 Жыл бұрын
Good work, this is working.
@parveen8122
@parveen8122 Жыл бұрын
@chaitanya Panchal if we have 5,2 and 2,5 and 6,1. sum of all three is same but not all are reverse. hence add a+b = b+a and a-b = b-a
@jatinnandwani6678
@jatinnandwani6678 2 жыл бұрын
Thanks so much
@jagatkrishna1543
@jagatkrishna1543 2 жыл бұрын
Thanks Sir 🙏💕
@RitikaSingh-in6dt
@RitikaSingh-in6dt 2 жыл бұрын
Here is my solution: With number_pairs1 As( Select A,B, CASE WHEN A>B THEN B ELSE A END AS A1, CASE WHEN A>B THEN A ELSE B END AS B1 FROM number_pairs) SELECT T.A, T.B FROM ( SELECT A,B, ROW_NUMBER() OVER(PARTITION BY A1,B1 ORDER BY A ASC) AS ROW FROM number_pairs1) AS T WHERE T.ROW=1; Open for recommendations.
@AftabAlam-lh1fe
@AftabAlam-lh1fe 2 жыл бұрын
I am MBA non IT background, having 13 years experience. Is it possible to become data engineer, and is it good idea for me? Pls guide
@tanushreesaha2276
@tanushreesaha2276 2 жыл бұрын
SELECT * FROM NUMBER_PAIRS WHERE A IN(1,3,4,5) and B in(2,2,6,2); 😅😅😅😅😅😅
@jaikishankumar3377
@jaikishankumar3377 Жыл бұрын
If the data looks like: A B 1 1 2 2 1 1 2 2 Then, the same approach and DISTINCT or GROUP BY can be added
@rakeshd7131
@rakeshd7131 2 жыл бұрын
select * from table_name where (c1,c2) in (select c2,c1 from table_name);
@rakeshd7131
@rakeshd7131 2 жыл бұрын
a little correction,add 'not in; instead of 'in'
@infinity5503
@infinity5503 2 жыл бұрын
We need one pair but this will eliminate both pair
@VijayVijay-pn3cp
@VijayVijay-pn3cp 2 жыл бұрын
Hey shashank,,please clear me out from this doubt. I know I feel this question is not Related to you. But I value your Suggestion I'm done diploma in mechanical engineering. & working as a designer engineer (catia v5) in Automotive Industry. Can you suggest me to level up my career or any other best job opportunities to get around 8LPA..
@sandipansarkar9211
@sandipansarkar9211 2 жыл бұрын
finished watching
@kikikiki4588
@kikikiki4588 2 жыл бұрын
Please create playlists for SQL videos so that we can easily access them.
@kikikiki4588
@kikikiki4588 2 жыл бұрын
Thank you
@liveeatwork3601
@liveeatwork3601 2 жыл бұрын
Do we have any platform for data professionals similar to crio which provides learning opportunities and job opportunities for good companies?
@SonicPlus-Studio
@SonicPlus-Studio 2 жыл бұрын
Sir Btech from tier 3 college or BCA + MCA from good college which is best one please reply Or make video on this
@VamsiKrishna-je3iy
@VamsiKrishna-je3iy 2 жыл бұрын
Please more of aggregate functions in sql using group by having partition by for department wise problems it's getting worse for me
@yourajbadgujar7837
@yourajbadgujar7837 2 жыл бұрын
sir mysql aur sql server me kyon sa job ke liya acha hoga?
@dishitaneve8362
@dishitaneve8362 2 жыл бұрын
Please make more such video
@akshaybaura
@akshaybaura 2 жыл бұрын
select a as col1, b as col2 from number_pairs union select b as col1, a as col2 from number_pairs
@Vikrammaity
@Vikrammaity 2 жыл бұрын
hi shashank... looks like approach 1 will fail for record with (4,4) (5,5) (6,6)
@shashank_mishra
@shashank_mishra 2 жыл бұрын
Yes I discussed about this point in Problem Statement Timestamp
@AbhishekKumar-bh3lx
@AbhishekKumar-bh3lx 2 жыл бұрын
We can also create key based on sum and product of A and B.
@infinity5503
@infinity5503 2 жыл бұрын
Will it work if we have pair like 3,7 and 5,5
@AbhishekKumar-bh3lx
@AbhishekKumar-bh3lx 2 жыл бұрын
@@infinity5503 Yes right. 3,7 = 10:21 5,5 = 10:25 key of sum & product should still remain distinct.
@infinity5503
@infinity5503 2 жыл бұрын
@@AbhishekKumar-bh3lx you can use partition by min(a,b), max(a,b).
@jeekakrishna
@jeekakrishna 2 жыл бұрын
nice
@RAHULRAJ-xh5fy
@RAHULRAJ-xh5fy 2 жыл бұрын
NEED HELP PLEASE....plz guide Sir, I am getting project in Oracle PL/SQL,Linux Shell scripting will it help in future while switching to data science field.my core ares of interest in big data and data science, i don't know what to do if I refuse the project they will put in bench
@ravindra2141
@ravindra2141 2 жыл бұрын
from personal experience , yes . oracle and pl/sql will help you and shell scripting is always helpful . however they will give you strong roots but you wont get into big data or data science or cloud with them . you can pursue courses in parallel according to your interest and apply for roles .
@RAHULRAJ-xh5fy
@RAHULRAJ-xh5fy 2 жыл бұрын
@@ravindra2141 thanku so much bhaiya
@harshkulkarni7729
@harshkulkarni7729 2 жыл бұрын
SELECT * FROM number_pairs GROUP BY a+b,a*b
@softtoysindia
@softtoysindia 2 жыл бұрын
what is the sure that u got job in google...please show credential ...lot of fake people are there
The 25 SQL Questions You MUST Know for Data Analyst Interviews
32:47
KSR Datavizon
Рет қаралды 224 М.
🍉😋 #shorts
00:24
Денис Кукояка
Рет қаралды 2,8 МЛН
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 64 МЛН
Amazon Data Engineer Streaming and Analytics Interview
50:34
Jay Feng
Рет қаралды 10 М.
Google Data Engineer Interview Experience
16:46
Jash Radia
Рет қаралды 38 М.
Uber Data Engineer Interview: Design a Ride Sharing Schema
29:39
Top 10 Data Analyst Interview Questions (with answers)
15:58
🍉😋 #shorts
00:24
Денис Кукояка
Рет қаралды 2,8 МЛН