Skip to content

Commit 8f048fa

Browse files
refactor 571
1 parent 53c9369 commit 8f048fa

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

Diff for: database/_571.sql

-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
--571. Find Median Given Frequency of Numbers
2-
-- The Numbers table keeps the value of number and its frequency.
3-
--
4-
--+----------+-------------+
5-
--| Number | Frequency |
6-
--+----------+-------------|
7-
--| 0 | 7 |
8-
--| 1 | 1 |
9-
--| 2 | 3 |
10-
--| 3 | 1 |
11-
--+----------+-------------+
12-
--
13-
--In this table, the numbers are 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, so the median is (0 + 0) / 2 = 0.
14-
--
15-
--+--------+
16-
--| median |
17-
--+--------|
18-
--| 0.0000 |
19-
--+--------+
20-
--
21-
--Write a query to find the median of all numbers and name the result as median.
22-
231
select FORMAT(avg(n.Number),4)*1.0 as median
242
from Numbers n left join
253
(

0 commit comments

Comments
 (0)