Rank() vs. Dense Rank () vs. Percent Rank () vs. Cumulative Distribution in SQL

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

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

  • @muhammadasim8873
    @muhammadasim8873 4 года назад +2

    Wonderfull Tutorial.... clearly and precisely explained... in less than 10 minutes... Bravo....

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

      Thanks a lot, friend. More coming soon !!
      So, Stay tuned...

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

    Great content

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

    you are showing how to use percent rank and cume_dist...not what they are and what they are doing....how do we interpret the results?

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

      Check the docs.Microsoft,
      Cume_dist function calculates the cumulative distribution of a value within a group of values. In other words, CUME_DIST calculates the relative position of a specified value in a group of values. Assuming ascending ordering, the CUME_DIST of a value in row r is defined as the number of rows with values less than or equal to that value in row r, divided by the number of rows evaluated in the partition or query result set. CUME_DIST is similar to the PERCENT_RANK function which returns the rank of a value in a data set as a percentage of the data set. This function can be used to evaluate the relative standing of a value within a data set. For example, you can use PERCENTRANK to evaluate the standing of an aptitude test score among all scores for the test

  • @954giggles
    @954giggles 2 года назад +1

    What if you have null values in PERCENT_RANK

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

      Can you send me a sample data and I can check and get back.. dataandyou@gmail.com

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

    Thanks

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

    how can we get only rank 1 records in the given syntax =

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

      Does this help ? Alias(rename) the rank column and then Add a where clause to filter out the rank =1.

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

    If I wanted to reference these columns for a later calculation. Would I need to add them to the data?

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

      Thanks for the comment. You are correct. You need to add it as a column to an entity(Table or View). You can create a table something like this... CREATE TABLE new_table
      AS (SELECT * .......) alternatively you can also create a view and then reference the view. Remember the view will not have memory and will reference the table behind it when you call it.