Help with an SQL query on a single (comments) table (screenshot included)
- by citrus
Please see screenshot
Goal:
id like to have comments nested 1 level deep
The comments would be arranged so that rating of the parent is in descending order
the rating of the children comments is irrelevant
The left hand side of the screenshot shows the output that Id like. The RHS shows the table data. All of the comments are held in 1 table.
Im a beginner with SQL queries, the best I can do is:
SELECT *
FROM [Comments]
WHERE ([ArticleId] = @ArticleId) ORDER BY [ThreadId] DESC, [DateMade]
This somewhat does the job, but it obviously neglects the rating. So the above statement would show output where Bobs Comment and all of the children comments are before Amy's and her childrens comments.
How can I run this query correctly?