使用 CREATE TABLE <name> AS SELECT 在 SQLite 中创建 table 时出错

Error creating a table in SQLite using CREATE TABLE <name> AS SELECT

我正在尝试创建一个日期 table 来为特定日期范围生成 EOM 日期,但是 SQLite 在创建 table 时抛出错误。我目前的代码如下:

WITH RECURSIVE cnt (
        x
) AS (
    SELECT
            0
    UNION ALL
    SELECT
            x + 1
    FROM
            cnt
    LIMIT (
            SELECT
                    ROUND(((julianday ('2020-05-01') - julianday ('2016-04-01')) / 30) + 1))
)

CREATE TABLE report_dates AS
SELECT
  date(date(julianday ('2016-04-01'), '+' || x || ' month'), '-1 day') AS month
FROM
  cnt;

但是,我收到错误 Query 1 ERROR: near "CREATE": syntax error。删除 CREATE TABLE report_dates AS 行不会使结果出现问题。是什么原因造成的?

cte 在 create table 之后:

CREATE TABLE report_dates AS
WITH RECURSIVE cnt (x) AS (
    SELECT 0
    UNION ALL
    SELECT x + 1
    FROM cnt
    LIMIT (
        SELECT ROUND(((julianday ('2020-05-01') - julianday ('2016-04-01')) / 30) + 1)
    )
)
SELECT date(date(julianday ('2016-04-01'), '+' || x || ' month'), '-1 day') AS month
FROM cnt;