我有两个分开的查询:
SELECT avg(priv_even_price) FROM private_event;
输出
"AVG(PRIV_EVEN_PRICE)"
"387.833333333333333333333333333333333333"
和
SELECT max(priv_even_price) FROM private_event;
输出
"MAX(PRIV_EVEN_PRICE)"
"950"
如果我将这两者合并,为什么它不起作用,我在以下查询中收到错误:
SELECT max(priv_even_price) - (SELECT avg(priv_even_price) FROM private_event)
FROM private_event;
ORA-00937: not a single-group group function
00937. 00000 - "not a single-group group function"
*Cause:
*Action:
Error at Line: 1 Column: 39
答案 0 :(得分:3)
每次都不要写SELECT
,只需将函数作为表达式的一部分调用。
SELECT MAX(priv_even_price) - AVG(priv_even_price)
FROM private_event;
答案 1 :(得分:1)
试
SELECT
(SELECT max(priv_even_price) FROM private_event)
- (SELECT avg(priv_even_price) FROM private_event) AS Difference
答案 2 :(得分:0)
SELECT max(priv_even_price)-avg(priv_even_price) "Difference" FROM private_event