Table Join with Max.

  • I have two tables Ticket and Thread. They have TicketID in common. Thread has several rows with the same TicketID in them. I only want to join the ticket and threads table with the latest Thread_Date in the thread table. I am not sure of the query that is needed. That is the simple scope, but i need to query several other pieces of data from the ticket table but nothing special, if this matters.

    Thanks,

    Neil

  • select *

    from

    Ticket ti

    inner join Thread th on ti.TicketID = th.TicketID

    where

    th.Thread_Date = (select max(Thread_Date) from Thread where TicketID = ti.TicketID)

    Regards,

    Andy Jones

    andyj93@hotmail.com

    .

  • I just got that and it worked. I guess after talking it out and writing it in here it seemed a lot easier 🙂

    Thanks!

    Neil

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

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