Skip to Main Content
  • Questions
  • Retrieving just the 1st record from each group of accounts

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sean.

Asked: September 05, 2017 - 3:43 pm UTC

Last updated: September 06, 2017 - 1:22 am UTC

Version: Oracle 12.1

Viewed 1000+ times

You Asked

I have records in a marketer table and an account table that I want just the 1st account for each marketer that was notified on a specific date.
How can I do that with a query?

MARKETER
10033 COMPANY 1
10036 COMPANY 2
10044 COMPANY 3

ACCT
123 ACCOUNT A
125 ACCOUNT B
126 ACCOUNT C
127 ACCOUNT D
128 ACCOUNT E

MARKETER_ACCOUNT
10033 123
10033 125
10036 126
10044 127
10044 128

I would like just the 1st record for each Marketer so that I can sample if ALL Marketers were notified on their accounts.

I'm not sure how to do this when I have to link tables together and then restrict it to just the 1 account per Marketer.
Can you assist?


Expected outcome:
10033 123
10036 126
1044 127

and Connor said...

It's easy ... but you *did* read the guidelines about test cases yes ? Sigh

Anyway...here's a video walkthrough






Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.