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!

max function or alternative to cut down number of rows?

763900Jul 29 2010 — edited Jul 29 2010
Hello All,

I have a query that brings back a number of Deals from a table (DEAL). Each deal has one or many Services from a table (SRVC) associated with it. The query is currently joined on where DEAL.DEALID = SRVC.DEALID.

This brings back more rows than I need, I'm not interested in all of the Services per deal, just the one with the highest ID number will do for my purposes.

I do not know how to bring back a single row for each deal ID and discard the excess rows brought about by the multiple services? Can I use a MAX function or something like that?

SELECT
DEAL.DEALID,
SRVC.SRVCID
FROM
DEAL,
SRVC
WHERE
DEAL.DEALID = SRVC.DEALID
AND SRVC.SRVCTYPID IN (6)

I had expected this to be quite simple but I'm really scratching my head over it, really appreciate any help!

Thanks

Jon
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2010
Added on Jul 29 2010
7 comments
2,680 views