I've got a forum running off two basic tables: forum_threads and forum_posts:
forum_threads columns:
id
subject
forum_posts columns:
id
thread_id
post_date
body
I've got the following script, that creates a list of forum threads ordered by which threads were most recently added to (ie: which enrty in the forum_posts table has the most recent date). If that makes sense:
SELECT TOP 10 CONVERT(varchar(20 ), forum_posts.post_date) AS last_post_date, forum_threads.id, forum_threads.subject
FROM forum_threads INNER JOIN forum_posts ON forum_posts.thread_id = forum_threads.id
ORDER BY forum_posts.post_date DESC
Trouble is, if there's more than one entry on the forum_posts table with a particular thread_id, then it pulls out all of 'em. What I want it to do is pull out the top 10 recently-added-to threads but only those with distinct thread_id's.
I tried sticking DISTINCT in front of forum_threads.id, but that threw an error.
Can anyone point me in the right direction? Many thanks.