このテーブルを考えると:
オーダー
custName description to_char(price)
A desa $14
B desb $14
C desc $21
D desd $65
E dese $21
F desf $78
G desg $14
H desh $21
価格が最も高い行全体、この場合は $14 と $21 を表示しようとしています。
サブクエリが必要だと思います。だから私はこれから始めました:
select max(count(price))
from orders
group by price
それは私に3を与えます。
しばらくすると、それは役に立たないと思いました。カウントではなく値14と21が必要だったと思うので、それをwhere句に入れることができます。しかし、それを表示する方法に行き詰まっています。助けはありますか?
更新:だから、これから14と21を照会するようになりました
select price
from orders
group by price
having (count(price)) in
(select max(count(price))
from orders
group by price)
しかし、エラーが発生した custname と description 列を表示する必要があります。
select custname, description, price
from orders
group by price
having (count(price)) in
(select max(count(price))
from orders
group by price)
SQL Error: ORA-00979: not a GROUP BY expression
これについて何か助けはありますか?