I have a table in the MSSQL database that looks like this:
Timestamp (datetime)
Message (varchar(20))
Once a day, a specific process inserts the current time and the message "Start" when it starts. When it is completed, it inserts the current time and the message “Finish”.
What is a good query or a set of instructions that, given a specific date, are returned:
- 0 if the process did not start
- 1, if the process began, but did not end
- 2, if the process started and ended
There are other messages in the table, but "Started" and "Finished" are unique to this process.
EDIT: For bonus karma, raise an error if the data is invalid, for example, there are two “Start” messages, or there is “Finished” without “Start”.