I am trying to find an elegant solution in the form of a SQL query for the following problem.
New records will be inserted in the Log table. I need to detect any new records (inserted in the last hour) that I haven't seen before and generate an alert (e.g. # of these records > 0)
ID, Url, DOB
1, site1.com/page1, "5/06/2012 20:01"
2, site2.com/page2, "5/06/2012 21:20"
3, site1.com/page1, "6/06/2012 10:05"
If "now" is 6/06/2012 10:40 - I see that there was 1 new record (id=3) inserted but I don't want to generate an alert because we have seen this URL before (id=1).
if we have 4, site3.com/pageX, "6/06/2012 10:08" then I want to generate an alert (return count=1) because this row was inserted in the last hour and we haven't seen it before.
What is the best way to implement it? ideally without nested queries