Skip to content

Commit ff9c172

Browse files
committed
Upload 143
1 parent 13ff2ef commit ff9c172

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ The problems and both submitted and site solutions are documented in individual
175175
| 140 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date/description/) | [Solution](solutions/140_group_sold_products_by_the_date.md) | DataLemur | Easy | `GROUP_CONCAT()` |
176176
| 141 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period/) | [Solution](solutions/141_list_the_products_ordered_in_a_period.md) | DataLemur | Easy | |
177177
| 142 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date/description/) | [Solution](solutions/142_product_price_at_a_given_date.md) | LeetCode | Medium | `UNION ALL`, `LEFT JOIN`, Window Function |
178+
| 143 | [Rank Scores](https://leetcode.com/problems/rank-scores/description/) | [Solution](solutions/143_rank_scores.md) | LeetCode | Medium | |
178179
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
179180

180181
## Author(s)

solutions/143_rank_scores.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SQL Everyday \#143
2+
3+
## Rank Scores
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
Write a solution to find the rank of the scores. The ranking should be calculated according to the following rules:
11+
12+
* The scores should be ranked from the highest to the lowest.
13+
* If there is a tie between two scores, both should have the same ranking.
14+
* After a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no holes between ranks.
15+
16+
Return the result table ordered by `score` in descending order. [[Full Description](https://leetcode.com/problems/rank-scores/description/)]
17+
18+
## Submitted Solution
19+
20+
```sql
21+
-- Submitted Solution
22+
SELECT
23+
score
24+
,DENSE_RANK() OVER (ORDER BY score DESC) AS rank
25+
FROM Scores
26+
;
27+
```
28+
29+
## Site Solution
30+
31+
```sql
32+
-- LeetCode Solution
33+
-- TBD
34+
```
35+
36+
## Notes
37+
38+
TBD
39+
40+
## NB
41+
42+
TBD
43+
44+
Go to [Index](../?tab=readme-ov-file#index)\
45+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)