我有以下场景
CREATE TABLE plch_sales
(
region VARCHAR2 (100),
product VARCHAR2 (100),
amount NUMBER
)
/
INSERT INTO plch_sales VALUES ('North', 'Magic Wand', 1000);
INSERT INTO plch_sales VALUES ('North', 'Skele-Gro', 1000);
INSERT INTO plch_sales VALUES ('North', 'Timeturner ', 1000);
INSERT INTO plch_sales VALUES ('South', 'Portkey', 1000);
INSERT INTO plch_sales VALUES ('South', 'Quaffle', 1000);
INSERT INTO plch_sales VALUES ('West', 'Imperius', 1000);
INSERT INTO plch_sales VALUES ('West', 'Gringotts', 1000);
COMMIT;
为什么以下查询没有返回任何行?数据库是Oracle。
select region, sum(amount) sm_amount from PLCH_SALES group by region having sum(amount) > (select sum(amount)/3 from PLCH_SALES);
.. > (select sum(amount)/3 + 0 from PLCH_SALES)
。 - Serg