Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3dfe235

Browse files
authored
Update readme.md
1 parent 18a2528 commit 3dfe235

File tree

1 file changed

+34
-4
lines changed
  • src/main/java/g0101_0200/s0178_rank_scores

1 file changed

+34
-4
lines changed

‎src/main/java/g0101_0200/s0178_rank_scores/readme.md‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ SQL Schema
66

77
Table: `Scores`
88

9-
+-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | score | decimal | +-------------+---------+ id is the primary key for this table. Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
9+
+-------------+---------+
10+
| Column Name | Type |
11+
+-------------+---------+
12+
| id | int |
13+
| score | decimal |
14+
+-------------+---------+
15+
id is the primary key for this table.
16+
Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
1017

1118
Write an SQL query to rank the scores. The ranking should be calculated according to the following rules:
1219

@@ -20,6 +27,29 @@ The query result format is in the following example.
2027

2128
**Example 1:**
2229

23-
**Input:** Scores table: +----+-------+ | id | score | +----+-------+ | 1 | 3.50 | | 2 | 3.65 | | 3 | 4.00 | | 4 | 3.85 | | 5 | 4.00 | | 6 | 3.65 | +----+-------+
24-
25-
**Output:** +-------+------+ | score | rank | +-------+------+ | 4.00 | 1 | | 4.00 | 1 | | 3.85 | 2 | | 3.65 | 3 | | 3.65 | 3 | | 3.50 | 4 | +-------+------+
30+
**Input:**
31+
32+
Scores table:
33+
+----+-------+
34+
| id | score |
35+
+----+-------+
36+
| 1 | 3.50 |
37+
| 2 | 3.65 |
38+
| 3 | 4.00 |
39+
| 4 | 3.85 |
40+
| 5 | 4.00 |
41+
| 6 | 3.65 |
42+
+----+-------+
43+
44+
**Output:**
45+
46+
+-------+------+
47+
| score | rank |
48+
+-------+------+
49+
| 4.00 | 1 |
50+
| 4.00 | 1 |
51+
| 3.85 | 2 |
52+
| 3.65 | 3 |
53+
| 3.65 | 3 |
54+
| 3.50 | 4 |
55+
+-------+------+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /