How would I create this SQL?

  • I have a table that has a customer number and a date(among other info). I have multiple customer number entries for each customer. I want to get a list of the last entry for each customer number.

    Thanks in Advance

    Dave

  • Use a subquery grouping on customer number grabbing maxDate. Join that subquery back to the main table as a restriction so you only pull the last record per customer.

    If you'd like example code please provide sample schema and data in consumable form.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Craig, Thanks for the reply. Guess I just needed pointing the right direction. Think I got it now.

    Thanks again

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

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