webressurs
asked on
SortBy question
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:
ID (int)
Title (varchar)
Created (SmallDateTime)
LastReply (SmallDateTime)
How to solve this? Hope someone please can help me!
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:
ID (int)
Title (varchar)
Created (SmallDateTime)
LastReply (SmallDateTime)
How to solve this? Hope someone please can help me!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks :)
Open in new window
Raj