Define a table divisors in which each row describes the number of unique divisors for an integer up to 100. For example, the number 16 has five unique divisors: 1, 2, 4, 8, and 16.
The create table divisors as
Select
Example:
Select * from divisors limit 20;
- Expected output:
- | 1
- | 2
- 3 | 2
| 3-4
- 5 | 2
4-6 |
- 7 | 2
- 8 | 4
- 9 | 3
- 10 | 4
11 | 2
-6-12 |
13 | 2
-4-14 |
4-15 |
- 16 | 5
- 17 | 2
18 | 6
-19 | 2
-- 20 | 6
CodePudding user response:
Don't understand this requirement, the original poster can go into more detail about it?CodePudding user response:
WITH T AS(SELECT LEVEL AS L
The FROM DUAL
CONNECT BY LEVEL & lt; 100)
The SELECT a. | | '| | | COUNT (B.L) AS D
The FROM T A
LEFT the JOIN T B
ON a. & gt;=B.L
WHERE the MOD (a., B.L)=0
GROUP BY a.
The ORDER BY a.