Whats wrong with my SQL query?
- by William
I'm trying to set up a query that shows the first post of each thread and is ordered by the date of the last post in each thread. I got the first part down with this query:
SELECT *
FROM (
SELECT Min( ID ) AS MinID
FROM test_posts
GROUP BY Thread
)tmin
JOIN test_posts ON test_posts.ID = tmin.MinID
Now I need to figure out how to call the last post of each thread into a table, than use that table to order the first tables results. So far I got this, but it doesn't work.
SELECT *
FROM (
SELECT Min( ID ) AS MinID
FROM test_posts
GROUP BY Thread
)tmin
JOIN test_posts ON test_posts.ID = tmin.MinID
ORDER BY (SELECT MAX( ID ) AS MaxID, Thread, MAX( Date )
FROM test_posts
GROUP BY Thread
)tmax
tmax.Date