【发布时间】:2015-11-15 22:19:46
【问题描述】:
我正在尝试使用最常用的 ram 配置查找每个模型的查询。
表:
PC (code, model, speed, ram, hd, cd, price)
到目前为止,我能够列出每个型号的每个 ram 配置以及 ram 配置的使用次数。
select model, ram, max(config)
from (select model,ram,count(ram) as config
from pc
group by model, ram)
group by model, ram
输出:
MODEL RAM MAX(CONFIG)
------- ---- -----------
1232 64 2
1232 32 2
1233 128 3
1121 128 3
1233 64 1
1260 32 1
当我尝试列出具有最常用内存的模型时遇到问题。
select model, ram
from (select model, ram, count(ram) as config
from pc
group by model, ram)
group by model
having config = max(config);
Error : ORA-00979: not a GROUP BY expression
【问题讨论】:
标签: sql oracle group-by having ora-00979