Posted on 2011-03-19
I have a table storing topics. Each topic contains 2 smalldatetime fields: "Created" and "LastReply". If the topic has no replies the "LastReply" field is NULL.
I need to make a SELECT statement that get the last activity. This means: I need to get the 5 last records that is created OR replied.
The question is how to do this? Is the solution to compare "Created" and "LastReply" for each record, and make a new field (called "LastActivity") with the "newest" date? Then, I need to sort the records by "LastActivity"?
The table is like this:
How to solve this? Hope someone please can help me!