SQL for 1 to 100 prime numbers

Source: Internet
Author: User

Someone asked how to ask for 1 to 100 of prime numbers, so try to write a SQL

With X1 as (select-level + 1 AS-ID from dual CONNECT to level <=), X2 as (select a.ID, a.id/b.id as num from X1 A, X1 b where a.id <> b.id) SELECT DISTINCT ID from x2 where ID not in (SELECT DISTINCT ID from x2 where num is not like ' %.% ') ORDER by 1 ID----------2 3 5 7111317192329313741434753596167717379838997


This article is from the "focus on Oracle Performance Tuning" blog, reproduced please contact the author!

SQL for 1 to 100 prime numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.