Getting a list of nodes of a certain type sorted by number of votes
You can use views module to list nodes sorted by votes..

You can see the query executed in views when you enable Show SQL Query in views settings (admin/structure/views/settings) in the view preview...