Well, if you happen to be using Sql Server you can do that sort of thing in T-Sql. In Oracle, you can also accomplish the same thing using pl/sql. Either way i'd do it in a stored ...
You could also add the row in the SQL query. SELECT MAX (TimeStamp) TimeStamp, COUNT (*) RowCount FROM ... And check RowCount first. Second suggestion worked! The first suggesiton didn't work because ...