Reputation: 259
I have a database with a table 'Posts Table'.
In this table there are posts id, count user comment and count visitors comment.
I want to extra the top posts which have most comments
But the problem is there is two columns for comment (users comment, visitors comment).
I want the result like this , (usercomment + visitors comment) ,
How can I use SQL to do this?
Upvotes: 0
Views: 62
Reputation: 6876
SELECT *
FROM Posts
ORDER BY UserComments + VisitorComments DESC
That ought to do the trick
Upvotes: 3
Reputation: 6322
select * from Posts order by UserComments + VisitorComments desc
You need the DESC otherwise I believe it defaults to ASC
Upvotes: 0