Row Number Function in MySQL | Important SQL Interview Question

Поделиться
HTML-код
  • Опубликовано: 16 окт 2024

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

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

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

  • @pridename2858
    @pridename2858 Год назад +3

    Excellent learning...getting so easy to understand and learning of SQL's most clever tricks....Thank you sir

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

    Thank you so much sumit sir...Its quite easy to understand... Previously I had seen several vdo's but I can't get the actual purpose of using row_number & over clause... Some of the lectures they used the terms window - window which is quite tough to understand it... Thank you so much sir🙏🏻🙏🏻🙏🏻

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

    Simple, smooth & very much practical example & tutorial.

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

    thank you so much sir .... this video gave me nice clarification on row number ... your way of explaination is simply awesome ... and very helpful in understanding the topic .. :)

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

    Thank you so much Sir, you explain better than many paid training and school

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

    thanks for such a wonderful tutorial.
    I have been following your content for a long time.

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

    Thank Q sir..
    If it is possible can you make one video related to Date functions and some scenarios

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

    Very nice and cristal clear explanation sir of the row function appreciate your work. Congratulations you got one subscriber 🎉 keep it up sir 👍

  • @Akashsingh-re9dk
    @Akashsingh-re9dk 2 года назад +1

    select * from employee order by salary desc limit 4,1; One from many possible solution said by sumit sir to fetch the 5th highest salary. This querry too I got to know well from your sql sessions.

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

      But this doesn't show rownumber 5
      It's gives only 5th highest salary

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

      You can calculate the 5th highest salary in different ways
      1) by using order by clause with desc & then apply limit fn
      2) u can get it by using row_number and over clause also...

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

      To get 5th highest salary from dataset, It should be like:
      SELECT * FROM (select * from employee order by salary desc limit 5 offset 4) temptable LIMIT 1;

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

    As always Excellent tutorial. Thanks a lot for sharing this video.

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

    Very helpful. Thank you!

  • @sibghaBiz
    @sibghaBiz 9 месяцев назад

    you nailed it

  • @kmyamuna6719
    @kmyamuna6719 2 месяца назад

    Hi Sumit sir, one doubt here with partition by. There are 2 persons with same salary for banglore location. Is there any way to fetch both the person details for banglore location as there are multiple persons with the same highest salary

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

    thank u
    sir...

  • @muthu_vrn
    @muthu_vrn 6 месяцев назад

    Fantastic

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

    Grt lesson on row number, I have one question if I want to assign row num as lets say 1 to all emp. Whose salary is 20000/- then how can you modify it? Here in your query if two emp are earning 20000/- then row num is assigning 1 and 2 but i want same row num for both as salary is same of both. I hope you're getting my confusion??

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

      we will learn Rank and Dense Rank in upcoming sessions. your question will be answered there.

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

    @3:30 Sir, for me it is working even without sepcifying order by

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

    Thank you sir👍

  • @kryurr
    @kryurr 11 месяцев назад

    Hello Sir. Thank you for an excellant tutorial
    Please help me with following where we were finding 5th highest salary using -
    select * from ( select name , salary , row_number() over (order by salary desc) as key from emp ) temptable where rownum=2
    It says "NO DATA FOUND". Could you please help ?
    - Keyur

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

    Hi Sir, Thanks for the detailed explanation. I have a doubt, Can't, we use the row_number() without order by clause? or is it like we shouldn't use the row_number() function without partition by or order by clauses in the over Clause?

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

      order by is mandatory whereas partition by optional for all the windowing function

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

    Incase of same salary in few rows, the row_number approach will fail. Right ?

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

    Pls make videos on PLSQL

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

    why for bangalore 1 record, it should show 2 records as bangalore holds two 1st rank right ??

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

    Sir please explain the temptable concept

    • @SrinivasMamidi-g2b
      @SrinivasMamidi-g2b Год назад

      we should give any alias name for that rownumber subquery , or else it will not allow u to fetch details from that, i suggest you to pls try code without giving name and u will come to know

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

    Lets assume the order by column is having NULL values then How will the rum_number() assign the values ?
    I have the same question for RANK and DENSE_Rank as well ?

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

    please cover 177 no leetcode question

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

    sir please also give use the table so dont need to write the query;

  • @ShivamSharma-ou1mz
    @ShivamSharma-ou1mz 2 года назад

    More correct way will be using Dense Rank function instead of Row Number for calculating Nth Salary

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

      Yes.. that we will cover in next section on how to optimize this solution

    • @SrinivasMamidi-g2b
      @SrinivasMamidi-g2b Год назад

      Yes, with Dense_rank we will get all the employess whose having same salary

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

    Pls send notes Sir

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

      Will try adding the link to it in the description section.

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

    please take regular expressions

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

    Samajh nhi aa raha

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

    plsql

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

    I got confusing 😭😭

  • @learner-xu5tw
    @learner-xu5tw Год назад +2

    CREATE TABLE employee (
    firstname varchar(20),
    lastname varchar(20),
    age int,
    salary int,
    location varchar(20)
    );
    INSERT INTO employee VALUES ('sachin', 'sharma', 28, 10000, 'bangalore');
    INSERT INTO employee VALUES ('shane', 'warne', 30, 20000, 'bangalore');
    INSERT INTO employee VALUES ('rohit', 'sharma', 32, 30000, 'hyderabad');
    INSERT INTO employee VALUES ('shikhar', 'dhawan', 32, 25000, 'hyderabad');
    INSERT INTO employee VALUES ('rahul', 'dravid', 31, 20000, 'bangalore');
    INSERT INTO employee VALUES ('saurabh', 'ganguly', 32, 15000, 'pune');
    INSERT INTO employee VALUES ('kapil', 'dev',34, 10000, 'pune');