For each ticketid above, select the row with least minimum date. Once that is done I want another column in my output called "isEngaged" which will be set to 1 if the ticketid has a type = 1 present for any of its records.