Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

query formulation help

758454Mar 14 2010 — edited Mar 15 2010
hi guys, basically I need to formulate a query which will give me the records in which the primary key appears the most on the table.

IE

AOI EID CID PRICES DATES
--- --- --- ---------- ---------
o10 e02 c11 330000 15-JUN-08
o17 e03 c13 500000 21-JUL-08
o18 e06 c16 515000 13-AUG-08
o22 e12 c15 395000 31-AUG-08
o13 e05 c14 90000 09-SEP-08
o15 e02 c17 95000 21-SEP-08
o20 e07 c13 500000 01-OCT-08
o16 e11 c15 100000 31-OCT-08
o19 e09 c16 250000 07-NOV-08
o22 e11 c17 420000 25-NOV-08
o21 e08 c13 420000 28-Aug-08

therefore if I wanted to formulate the query based on which EID has the most instances in the table, it would give me e02 and e11.

I'm not sure if im no the right track but I have been fooling around with the COUNT aggregate operator but to no avail. IE...

SELECT M.eid FROM MakesD3 M GROUP BY M.EID HAVING COUNT(*) >...

Thanks in advance for the help
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2010
Added on Mar 14 2010
3 comments
591 views