Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How does this really work if a developer wants to pull most recent discussions posted in in X category, having most number of replies when I only have to tables?


something like this?

SELECT TOP 50 * FROM [things] [post]

JOIN [things] [category] ON [category].[id] = [post].[parent_id]

WHERE [post].[type] = 'post'

AND [category].[type] = 'category' AND [category].[slug] = 'animal-pictures'

ORDER BY ([post].[child_count] / DATEDIFF('hh', [post].[created_date], GETUTCDATE()) DESC;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: