MonetDB 中的一个查询中的联合和限制

Union and limit in one query in MonetDB

如何在 MonetDB 中编写以下查询:

CREATE TABLE "sampled" AS (
 SELECT *
 FROM   "base"
 WHERE  "target" = 'B'
 LIMIT  30
) UNION ALL (
 SELECT * 
 FROM "base" 
 WHERE "target" = 'A' 
 LIMIT 30 
) WITH DATA

?

当我尝试执行上述查询时:

MonetDB Database Server Toolkit v1.1 (Oct2014-SP2)

OS X 10.9.5

我得到:

Error: syntax error, unexpected LIMIT, expecting INTERSECT or EXCEPT or UNION or ')' in: "create table "sampled" as (
SQLState:  42000
ErrorCode: 0 
Error:      select * 
SQLState:  22000 
ErrorCode: 0 
Error: from   "predictor_factory"."base"" 
SQLState:  22000 
ErrorCode: 0

Union 单独工作如预期:

SELECT *
FROM   "base"
WHERE  "target" = 'B'
UNION ALL
SELECT * 
FROM   "base"
WHERE  "target" = 'A'

单独限制也很有效:

SELECT * 
FROM   "base"
WHERE  "target" = 'A'
LIMIT  30

就是这个组合让我很头疼

MonetDB 在子查询中不支持 LIMIT。您可以执行以下操作

CREATE TABLE "sampled" AS SELECT * FROM "base" WHERE "target" = 'B' LIMIT 30 WITH DATA;
INSERT INTO "sampled" SELECT * FROM "base" WHERE "target" = 'A' LIMIT 30;