MySQL. We have a table that's the tickets. Then we have a table of ticket logs, each…
- User
MySQL. We have a table that's the tickets. Then we have a table of ticket logs, each record has an IdReference that is the Ticket's Id, a LogNumb which indicates the log number for that ticket (first log of the ticket has LogNumb 1, second log in the same ticket will have LogNumb 2 and so on), idoperator (which can be 0 if the log was from the customer, or an operator ID if it came from us) and it may or may not have an IdTkContact. Logs from customers (with idoperator = 0) never have IdTkContact; logs from operators (with idoperator > 0) may or may not have it. If IdTkContact isn't null, it'll be the id of a record from the table TkContacts, which has infos about a contact operator had with the customer. Amongst these, a column datetime_recontact is there, which indicates when the operators will have to re-contact the customer. But it can be null, sometimes the contact didn't agree on a re-contact.
I want a query that, given a ticket Id, gives me the last re-contact. With "last", I mean we take the last (highest LogNumb) operator log (idoperator > 0) of that ticket (identified with IdReference)... and then, if that log has no IdTkContact then nada, else we take the related record in TkContacts and get its re-contact column (datetime_recontact), whether it's NULL or valid. So I'll see NULL if there's no Log from the operators in that ticket, NULL if the latest operator Log has no contact (regardless whether previous operator logs had some), NULL if the latest operator Log has a contact with no re-contact date... and the re-contact date if there actually is one.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.