query to select topic with highest number of comment +support+oppose+views
- by chetan
table schema
title description desid replyto support oppose views
browser used a1 none 1 1 12
- bad topic b2 1 2 3 14
sql database a3 none 4 5 34
- crome b4 1 3 4 12
Topic desid starts with a and comment desid starts with b .For comment replyto is the desid of topic . Its easy to select * with highest number of support+oppose+views by query "select * from [DB_user1212].[dbo].[discussions] where desid like 'a%' order by (sup+opp+visited) desc"
For highest (comment +support+oppose+views ) i tried
"select * from [DB_user1212].[dbo].[discussions] where desid like 'a%' order by ((select count(*) from [DB_user1212].[dbo].[discussions] where replyto = desid )+sup+opp+visited) desc" but it didn't work . Because its not possible to send desid from outer query to innner subquery .