3 Very Important SQL Interview Questions on LeetCode | Practise SQL Questions

Поделиться
HTML-код
  • Опубликовано: 3 апр 2022
  • 𝐖𝐚𝐧𝐭 𝐭𝐨 𝐌𝐚𝐬𝐭𝐞𝐫 𝐒𝐐𝐋? 𝐋𝐞𝐚𝐫𝐧 𝐒𝐐𝐋 𝐭𝐡𝐞 𝐫𝐢𝐠𝐡𝐭 𝐰𝐚𝐲 𝐭𝐡𝐫𝐨𝐮𝐠𝐡 𝐭𝐡𝐞 𝐦𝐨𝐬𝐭 𝐬𝐨𝐮𝐠𝐡𝐭 𝐚𝐟𝐭𝐞𝐫 𝐜𝐨𝐮𝐫𝐬𝐞 - 𝐒𝐐𝐋 𝐂𝐡𝐚𝐦𝐩𝐢𝐨𝐧𝐬 𝐏𝐫𝐨𝐠𝐫𝐚𝐦 𝐛𝐲 𝐒𝐮𝐦𝐢𝐭 𝐒𝐢𝐫!
    "𝐀 8 𝐰𝐞𝐞𝐤 𝐏𝐫𝐨𝐠𝐫𝐚𝐦 𝐝𝐞𝐬𝐢𝐠𝐧𝐞𝐝 𝐭𝐨 𝐡𝐞𝐥𝐩 𝐲𝐨𝐮 𝐜𝐫𝐚𝐜𝐤 𝐭𝐡𝐞 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐬 𝐨𝐟 𝐭𝐨𝐩 𝐩𝐫𝐨𝐝𝐮𝐜𝐭 𝐛𝐚𝐬𝐞𝐝 𝐜𝐨𝐦𝐩𝐚𝐧𝐢𝐞𝐬 𝐛𝐲 𝐝𝐞𝐯𝐞𝐥𝐨𝐩𝐢𝐧𝐠 𝐚 𝐭𝐡𝐨𝐮𝐠𝐡𝐭 𝐩𝐫𝐨𝐜𝐞𝐬𝐬 𝐚𝐧𝐝 𝐚𝐧 𝐚𝐩𝐩𝐫𝐨𝐚𝐜𝐡 𝐭𝐨 𝐬𝐨𝐥𝐯𝐞 𝐚𝐧 𝐮𝐧𝐬𝐞𝐞𝐧 𝐏𝐫𝐨𝐛𝐥𝐞𝐦."
    𝐇𝐞𝐫𝐞 𝐢𝐬 𝐡𝐨𝐰 𝐲𝐨𝐮 𝐜𝐚𝐧 𝐫𝐞𝐠𝐢𝐬𝐭𝐞𝐫 𝐟𝐨𝐫 𝐭𝐡𝐞 𝐏𝐫𝐨𝐠𝐫𝐚𝐦 -
    𝐑𝐞𝐠𝐢𝐬𝐭𝐫𝐚𝐭𝐢𝐨𝐧 𝐋𝐢𝐧𝐤 (𝐂𝐨𝐮𝐫𝐬𝐞 𝐀𝐜𝐜𝐞𝐬𝐬 𝐟𝐫𝐨𝐦 𝐈𝐧𝐝𝐢𝐚) : rzp.io/l/SQLINR
    𝐑𝐞𝐠𝐢𝐬𝐭𝐫𝐚𝐭𝐢𝐨𝐧 𝐋𝐢𝐧𝐤 (𝐂𝐨𝐮𝐫𝐬𝐞 𝐀𝐜𝐜𝐞𝐬𝐬 𝐟𝐫𝐨𝐦 𝐨𝐮𝐭𝐬𝐢𝐝𝐞 𝐈𝐧𝐝𝐢𝐚) : rzp.io/l/SQLUSD
    𝐖𝐚𝐧𝐭 𝐭𝐨 𝐥𝐞𝐚𝐫𝐧 𝐁𝐢𝐠 𝐃𝐚𝐭𝐚 𝐛𝐲 𝐒𝐮𝐦𝐢𝐭 𝐒𝐢𝐫?
    𝐜𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐭𝐡𝐞 𝐛𝐢𝐠 𝐝𝐚𝐭𝐚 𝐜𝐨𝐮𝐫𝐬𝐞 𝐝𝐞𝐭𝐚𝐢𝐥𝐬
    𝐖𝐞𝐛𝐬𝐢𝐭𝐞 : trendytech.in/?src=youtube&su...
    I have trained over 20,000+ professionals in the field of Data Engineering in the last 5 years.
    3 Very Important SQL Interview Questions on LeetCode | Practise SQL Questions
    178. Rank Scores
    180. Consecutive Numbers
    181. Employees Earning More Than Their Managers
    Do Like, Comment & Subscribe ..
    𝗝𝗼𝗶𝗻 𝗺𝗲 𝗼𝗻 𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:🔥
    🔅Sumit LinkedIn - / bigdatabysumit
    🔅Sumit Instagram - / bigdatabysumit
    In this video, we will solve SQL question on LeetCode. LeetCode is an excellent platform for practicing SQL Queries. The SQL Questions on LeetCode are framed pretty similar to how they are asked on SQL Interviews hence solving SQL questions on LeetCode can give you a good hands on experience on solving real world SQL questions.
    #SQL #RDBMS #database #bigdata #dataengineering

Комментарии • 31

  • @sumitmittal07
    @sumitmittal07  Год назад

    Checkout the Big Data course details here: trendytech.in/?referrer=youtube_lc3

  • @mystuffstudy1403
    @mystuffstudy1403 2 года назад +2

    Thanks for these videos sir.
    for 180 this is another way of doing
    with cte as (
    select *, lead(val) over(order by id) 'nextval', lead(val,2) over(order by id) '2nd next val' from #test
    )
    select distinct [2nd next val] from cte where val = nextval and val = [2nd next val]

  • @rajorshi1000
    @rajorshi1000 2 года назад +8

    Thanks Sumit sir for such wonderful content and resolution. I have tried to resolve the problem-180 (Consecutive Numbers )with CTE and window function on my own and this is my 2 cents on it :
    with consecutive_val (num,next_val,next_to_next_val) as
    (select num , (lead(num,1) over (order by id asc)) as next_val , (lead(num,2) over (order by id asc)) as next_to_next_val
    from Logs)
    select distinct num as ConsecutiveNums from consecutive_val
    where num=next_val
    and num=next_to_next_val

    • @sumitmittal07
      @sumitmittal07  2 года назад +1

      That is nice. Keep practicing and improving on your skills

    • @rajorshi1000
      @rajorshi1000 2 года назад

      @@sumitmittal07 Thanks a lot for all the motivation.

  • @arunsundar3739
    @arunsundar3739 3 месяца назад

    able to understand when to use self-join & how to use self-join practically, SQL looks very interesting now, thank you very much sir :)

  • @swastiktripathy8412
    @swastiktripathy8412 2 года назад +2

    These videos are very helpful in getting clarity on such topics also this will help to crack interviews in the top IT firms. Thank you very much Sumit sir.

    • @sumitmittal07
      @sumitmittal07  2 года назад

      I am happy that you are finding it helpful!

  • @technicalknowledge9828
    @technicalknowledge9828 Год назад

    Thank you sumit for such useful videos

  • @dineshchavan9462
    @dineshchavan9462 2 года назад +1

    Hi sumit sir ..nice video..
    Just 1 question in problem number 180..what if we have string value instead of integers for ID column...please reply..

  • @nareshmallick6121
    @nareshmallick6121 2 года назад

    Very helpful to this video

  • @mallikarjunpatil7553
    @mallikarjunpatil7553 2 года назад +1

    Thanks for uploading...
    Waiting for next one

  • @ningus8522
    @ningus8522 Год назад

    Thank you sir...

  • @sameerpandey2344
    @sameerpandey2344 2 года назад +1

    love to watch your videos!!

    • @sumitmittal07
      @sumitmittal07  2 года назад

      I'm so glad you are loving the videos.

  • @karthikbs8457
    @karthikbs8457 2 года назад +2

    the second problem where you added 1 and 2 was quite confusing.

  • @kiran4608
    @kiran4608 2 года назад

    Sir what about java please make video on java interview

  • @dubeypushpendra4558
    @dubeypushpendra4558 Год назад

    plz solve more videos sir

  • @mubashirali9396
    @mubashirali9396 2 года назад +1

    lovely sumit sir

  • @shivangikhanna6163
    @shivangikhanna6163 Год назад +1

    I have one doubt here in problem statement 180. Consecutive Numbers. I understand we need to compare the ids in the join operation. But how is the = operator working. if logs l1 and l2 are pointing to same table,l1.id how is l1.id=l2.id+1 . isn't it comparing 1=2 in first case ? Will it not fail?

  • @girih-yt6de
    @girih-yt6de 3 месяца назад

    select num as ConsecutiveNums from( SELECT num,row_number() OVER (PARTITION BY num) as cu FROM Logs) where cu>=3; does this work for second problem?

  • @mukeshrajpurohit5593
    @mukeshrajpurohit5593 2 года назад +1

    For Q.180. Can’t we use Row Number partition by num, order by num and select Row Number > = 3??

    • @girih-yt6de
      @girih-yt6de 3 месяца назад

      select num as ConsecutiveNums from( SELECT num,row_number() OVER (PARTITION BY num) as cu FROM Logs) where cu>=3;

  • @amalkumar5201
    @amalkumar5201 Год назад

    Sir how to join your session

  • @santoshingle3977
    @santoshingle3977 7 месяцев назад

    For problem-180 (Consecutive Numbers ) - I have used LEAD function.
    select
    distinct num as ConsecutiveNums
    from
    (select num,
    LEAD(num, 1) OVER (ORDER BY id) as lead_1,
    LEAD(num, 2) OVER (ORDER BY id) as lead_2
    from Logs) as temp
    where
    temp.num=temp.lead_1 and temp.num=temp.lead_2

  • @kishorekunal7194
    @kishorekunal7194 2 года назад

    179 :
    SELECT s.score, DENSE_RANK() OVER(ORDER BY score DESC) AS rank
    FROM scores s
    ORDER BY s.score DESC;
    181:select
    E.name as employee
    from employee E
    where E.managerid is not null
    and E.salary > (select t1.salary from employee t1 where E.managerId = t1.id);

  • @sandeepmanjunath8004
    @sandeepmanjunath8004 Год назад

    Are these for beginners or for the ones with 1-2 years of experience ?

  • @satishraj5303
    @satishraj5303 Год назад

    it tried this way to get number which are repeting 3 time.
    -- create
    CREATE TABLE EMPLOYEE (
    id INTEGER PRIMARY KEY,
    number INTEGER NOT Null
    );
    -- insert
    INSERT INTO EMPLOYEE VALUES (1,1);
    INSERT INTO EMPLOYEE VALUES (2,1);
    INSERT INTO EMPLOYEE VALUES (3,1);
    INSERT INTO EMPLOYEE VALUES (4,2);
    INSERT INTO EMPLOYEE VALUES (5,2);
    INSERT INTO EMPLOYEE VALUES (6,3);
    INSERT INTO EMPLOYEE VALUES (7,3);
    -- fetch
    select t.number,count(t.number) from
    (select id,number,rank() over(order by id,number) as 'rank' from EMPLOYEE) t
    group by t.number
    having count(t.number)=3