Home > database >  Prime table SQL
Prime table SQL

Time:09-29


Thank you, online etc.
Define a table primes that has a single column containing all prime Numbers up to 100.

The create table primes as
Select
Here 's what your output should look like.

Example:
Select * from primes.
- Expected output:
2
-3
-5
-7
-11
-13
-17
-19
-23
-29
-31
-37
-41
-43
-47
-53
-59 -
- 61
- 67
- 71
- 73
- 79
- 83
- 89
- 97

CodePudding user response:

The solution? Through the function implementation can?

CodePudding user response:

WITH T AS
(SELECT ROWNUM + 1 RN
The FROM DUAL
CONNECT BY ROWNUM & lt;
=100-1)SELECT *
The FROM (SELECT an RN
The FROM T
MINUS
SELECT a T1. An RN * T2. RN
The FROM T T1, T T2
WHERE a T1. RN & lt;=T2. RN
AND T1. RN & lt;=(SELECT SQRT (100)
The FROM DUAL))
  • Related