SQL JOIN - retrieve MAX DateTime from second table and the first DateTime after previous MAX for other value
问题 I have issue with creating a proper SQL expression. I have table TICKET with column TICKETID TICKETID 1000 1001 I then have table STATUSHISTORY from where I need to retrieve what was the last time (maximum time) when that ticket entered VENDOR status (last VENDOR status) and when it exited VENDOR status (by exiting VENDOR status I mean the first next INPROG status, but only first INPROG after the VENDOR status, it's always INPROG the next status after VENDOR status). Also it is also possible