Select statement syntax

  • Good afternoon!

    I am stuck on a select statement.

    I have a table of prospect communication events. Each prospect has a unique prspct_id

    but each prospect has multiple communication events in the table. How can I select for the first (earliest event date) communication event for each prospect?

    This is probably simple but I am stuck at the moment. I end up with the earliest communication date in the table, not earliest for each prospect.

    Thank you

  • select stuff

    from prospects p1

    where p1.eventdate = (select min (p2.eventdate) from prospects p2 where p2.prspct = p1.prspct)

  • or

    select prspct_id,min(eventdate) from prospects group by prspct_id

    not sure which is best for performance though!

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Sorry about the delay responding, I do appreciate the help!

    Both approaches worked without a noticeable performance difference.

    Thanks!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply