Rank and Dense Rank in SQL Server

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

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

  • @88spaces
    @88spaces 5 лет назад +3

    I have said this before about you, but it bears repeating. You are the foremost expert on grouping data. I appreciate your videos and they have helped me a lot.

  • @krzysztofs8535
    @krzysztofs8535 7 лет назад +12

    Venkat rules! I'm the biggest fan of your tutorials. You are the best teacher in the world. God bless you for all your work and achievements. I learned a lot from your videos. Your explanations are fantastic and the way of your teaching is superb. Greatings from Poland !

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

    Hi Venkat,
    I wanted to take a moment to express my heartfelt gratitude for your exceptional teaching of programming. Your dedication and expertise have had a tremendous impact on my learning journey, and I am incredibly grateful for your guidance.
    Your ability to break down complex programming concepts into understandable chunks truly impressed me. Through your clear explanations and engaging teaching style, you made learning programming enjoyable and accessible.

  • @srujanareddy5185
    @srujanareddy5185 5 лет назад +1

    Omg...you are an amazing teacher. I feel too bad about not finding your tutorials until now. THANK YOU!

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 лет назад +2

      Hello Srujana - Thank you. Glad you are finding the videos useful. Means a lot. I have included all the SQL Course videos, slides and text articles in sequence on the following page. Hope you will find it handy.
      www.pragimtech.com/courses/sql-server-tutorial-for-beginners/
      If you have time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.

  • @rajreddy2561
    @rajreddy2561 7 лет назад +2

    Great explanation. One of the very few tutorials I have seen which is very clear and still very precise. Super job! Thanks Venkat

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

    That voice is ASMR to my ears.😌

  • @poorvi1036
    @poorvi1036 8 лет назад +14

    Thank you for all your tutorials..I love your explanations and your soothing voice.I wish I had your brain,you make it look so easy,lol.

  • @dhamma1283
    @dhamma1283 3 года назад

    Everytime I watch venkat tutorials, I like the video first and then I start. 👍

  • @dbin805
    @dbin805 8 лет назад +4

    thanks. this is the best explanation that I have seen for this.

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  8 лет назад +1

      +Dean Brandenburg Thanks a bunch for taking your valuable time to give feedback. Means a lot. Glad you found the videos useful.
      Dot Net & SQL Server videos for aspiring software developers
      ruclips.net/user/kudvenkatplaylists?view=1&sort=dd
      If you need videos for offline viewing, you can order them using the link below
      www.pragimtech.com/Order.aspx
      Code Samples, Text Version of the videos & PPTS on my blog
      csharp-video-tutorials.blogspot.com
      Tips to effectively use our channel
      ruclips.net/video/y780MwhY70s/видео.html
      Want to receive email alerts, when new videos are uploaded, please subscribe to our channel using the link below
      ruclips.net/user/kudvenkat
      Please click the THUMBS UP button below the video, if you think you liked them
      Thank you for sharing these links with your friends
      Best
      Venkat

  • @awengirr
    @awengirr 8 лет назад +1

    This was the best explanation ever. Thank you for that!

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

    Although this is an old video the explanation is a real gem. Timeless knowledge

  • @sumaiyamohiyuddin8173
    @sumaiyamohiyuddin8173 4 года назад

    Thanks a lot for ur explanation.The highlight is the clarity and simplicity of explanation

  • @absneo247
    @absneo247 7 лет назад

    Thanks very much for these videos.They are simple to understand and really helpful in learning query writing.

  • @liverickoben9922
    @liverickoben9922 4 года назад +1

    thanks for all your tutorials and clear explanations

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

    Super awesome, your explanations are truly good. I really learnt a lot from it....Thank you so much!!

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

    This helped me understand Rank better. Thank you.

  • @lilarasekh3818
    @lilarasekh3818 8 лет назад

    you guys are great! I learned a lot from your videos

  • @soniasadeque4248
    @soniasadeque4248 7 лет назад

    hats off to you.. you are a great teacher..

  • @pavithravvenu5817
    @pavithravvenu5817 3 года назад

    Great Videos and clear Explanation.Thanks a lot!!! it is very useful

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

    Hi Venkat, you are the best!!

  • @TheSwatirock
    @TheSwatirock 7 лет назад

    Thanks Professor..tutorial is quite helpful.

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

    Nice Explanation, Thankyou so much.

  • @surabhichouhan3758
    @surabhichouhan3758 4 года назад +1

    Hi
    Can we use rank, dense_rank or row_number functions over varchar columns?

  • @muhammadrehbarsheikh8498
    @muhammadrehbarsheikh8498 9 лет назад +1

    Thanks venkat sir!!

  • @nagatmohamed8246
    @nagatmohamed8246 9 лет назад +1

    Thanks a lot, sir.

  • @swetapanigrahi8001
    @swetapanigrahi8001 4 года назад

    Thank you.. Very nice tutorial

  • @TheHimaBindu
    @TheHimaBindu 9 лет назад +2

    Very informative

  • @mscreations183
    @mscreations183 5 лет назад

    Awesome teaching...👌👌👌

  • @102RC
    @102RC 7 лет назад

    Thank You Professor.

  • @samirkumar6180
    @samirkumar6180 3 года назад +1

    Hello sir, pls make video on table partitioning and their concept...this is something important which is not made yet

  • @chandrakumarreddyvennapusa7806
    @chandrakumarreddyvennapusa7806 4 года назад

    Fantastic

  • @optimistic_guy313
    @optimistic_guy313 3 года назад

    Thank you so much

  • @shariqahmed9416
    @shariqahmed9416 5 лет назад

    Nice explanation skills

  • @keyvansadeghi5743
    @keyvansadeghi5743 4 года назад

    Thank u bro that was helpful

  • @yogeshghule5260
    @yogeshghule5260 6 лет назад

    you are the great sir

  • @JohnDoe-dy4kf
    @JohnDoe-dy4kf 7 лет назад

    What are the advantages using of Rank() compared to GROUP BY or DISTINCT?

    • @ManishKumar-qx1kh
      @ManishKumar-qx1kh 3 года назад +1

      u cant group by for each record brother there will be only one record for each group. Rank with Over clause will give you each record separately.

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

    Thanka a lot sir

  • @korrapativinodkumar4760
    @korrapativinodkumar4760 6 лет назад

    EXCELLENT

  • @prashantparmar1397
    @prashantparmar1397 9 лет назад +1

    Please post video on how to populate calender

  • @aadityasharma9024
    @aadityasharma9024 3 года назад

    When you use Top 1 then it should be returning 1st row then what's the use of where clause with it?

  • @annwayde129
    @annwayde129 4 года назад

    Thanks a lot

  • @ting-kangpai1580
    @ting-kangpai1580 4 года назад

    Thank you!

  • @wwewwf324
    @wwewwf324 5 лет назад

    what is the use case of Rank function.Is there any scenario where we will use Rank?

  • @supercatsmari
    @supercatsmari 5 лет назад

    Thank you Venkat. I need some more information on this with join condition. Example i have employee table which has eno,ename,esal,edeptno columns, and another table (dept) which has dno,dname. Now i want to get the second max salary of "dname='Maths'". Please help me on this.

    • @MaheshBabu-vq7qk
      @MaheshBabu-vq7qk 4 года назад +1

      With EmployeeCTE as
      (
      select emp.Name as [Employee Name], Gender, Salary, dept.Name as [Department Name],
      Dense_Rank() over (partition by dept.Name order by Salary desc) DenseRank
      from tblEmployees emp
      inner join tblDepartment dept on emp.DepartmentId = dept.DepartmentId
      )
      Select Salary from EmployeeCTE where DenseRank = 2 and [Department Name]='Maths'
      With the above inner query in EmployeeCTE, we will get all the employee details like Employee Name, Gender, Salary, Department Name and Dense Rank partitioned by each department. Finally, we are getting second highest paid salary for the department "Maths" from the EmployeeCTE.

  • @anirbandas2062
    @anirbandas2062 6 лет назад

    I have a problem, where i am required to determine a Rank on a table on the basis of a derived column. Say first column desired is Name of Port, 2nd column is the sum of profit made on that port. The third column should be the rank based on the highest profit the port has. How can i create an sql query of rank on a derived column like the sum of total profit for each port? Hopefully you can give a suitable example.

  • @jorgegonzaloalfaro5378
    @jorgegonzaloalfaro5378 4 года назад

    Bro thank you!!!!

  • @raqibul1000
    @raqibul1000 9 лет назад +1

    Thanks a trillion

  • @rameshr5809
    @rameshr5809 6 лет назад

    Hello Venkat, you are my Dhronacharya,Thanks lot. Why we need to use top 1 in Result when we are filtering with Dense_Rank?

    • @MaheshBabu-vq7qk
      @MaheshBabu-vq7qk 4 года назад

      If we have 3 employees with second highest paid salary, we will get Salary three times in the result CTE. In order to avoid such kind of duplicate salaries, we can use either "top 1" or "distinct" keyword in the final select query.

  • @drallisimo34
    @drallisimo34 8 лет назад

    coooooooool tutorial!!!

  • @richardfrimpong3962
    @richardfrimpong3962 3 года назад

    Why is it desc because I see the values in Ascending order so can someone give me why?

  • @jsj14
    @jsj14 3 года назад

    What if there are 100Million rows in this table? Won't the order by take a lot of time while ranking

  • @shaikhzoyeb
    @shaikhzoyeb 3 года назад

    declare @tbl table
    (
    id int
    )
    insert into @tbl values (1),(1),(3),(4),(5)
    select
    rank() over (order by id) as Rank_,
    DENSE_RANK()over (order by id) as Dense_rank_
    from @tbl

  • @praveennagarajan1407
    @praveennagarajan1407 4 года назад

    Hi, How can I select top 3 of DENSE_RANK() ?

  • @quanhoang2139
    @quanhoang2139 8 лет назад

    thanks you

  • @Gamezone-kq5sx
    @Gamezone-kq5sx 6 лет назад

    want to find tob 5 highest product price in each category.In this case if there are one or more products with same price and if I use rank() then I get more than two record with rank 1 but I can't get rank with value 2 because there is tie.But in this case if I use dense_rank() then I get more than one records with dense_rank() of value 1 2 3 4 5.Please help

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

      Try select distinct rather than regular select with rank()

    • @AmitKumar-fr7gb
      @AmitKumar-fr7gb 2 года назад

      @@aaron2cool4u Thanks.. I had the same question.

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

    clean

  • @maryam4071
    @maryam4071 6 лет назад

    What’s tie? I can’t understand it.

    • @nys8260
      @nys8260 3 года назад

      notice in salary column there is two values 8000
      this is called tie (when there is more one value is similar)

  • @bhavyashreesarvamangala6775
    @bhavyashreesarvamangala6775 3 года назад

    Super super super duper

  • @gurungoracle
    @gurungoracle 8 лет назад

    how can I rank whole record only 1 through 10? not top n

    • @ManishKumar-qx1kh
      @ManishKumar-qx1kh 3 года назад

      use a CTE to rank them first and then select from the CTE where rank between to

  • @adithyagarigipati4205
    @adithyagarigipati4205 6 лет назад

    Can we start rank from a number we need ? Like 1000 ?

  • @krishnachaitanya9367
    @krishnachaitanya9367 9 лет назад +1

    Hi Venkat,
    Am very happy to see your videos.
    i have a small doubt in this video with the below query.
    with Result as
    (
    select salary,
    RANK() over (order by salary desc) as salaryrank
    from [dbo].[dense_employees]
    )
    SELECT TOP 1 salary from Result where salaryrank=1
    and my table structure is:
    CREATE TABLE [dbo].[dense_employees](
    [id] [int] NULL,
    [name] [varchar](30) NULL,
    [gender] [varchar](10) NULL,
    [salary] [int] NULL
    ) ON [PRIMARY]
    when am executing the above query in 2012 sql server its not giving output.its showing that "incorrect syntax near result".
    Please guide me how to execute this in 2012 sqlserver.
    it will be great if can you can help on this.
    when am browsing the internet some sites showing "with result sets" other than "with result as"
    Please guide me on this .
    Thnaks,
    Krishna

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Rank will omit whereas dense rank will not omit

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Ritesh Deshmukh

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Mechanical

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Madhuri Dixit

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Anil Kapoor

  • @shivarjunroy1394
    @shivarjunroy1394 5 лет назад

    Rank =1

  • @saahilsud8933
    @saahilsud8933 4 года назад

    What is with this fake accent man? It makes it so hard to focus on the lesson without getting irritated out of your mind. Who are you? Priyanka Chopra?

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

    Thanks!