Up vote 0 down vote favorite share g+ share fb share tw.
There are two tables- 1. Merchants and 2.ranking. Merchants- id, merchant_name, date and so on ranking - id,merchant_id, customer_id and so on (each customers ranking for merchants) I want to sort merchants details for asending using ranking.
How to write the selection query? Do I want to use subqueries? Thank you for the help!
Ruby-on-rails-3 link|improve this question edited Oct 19 '11 at 5:00chown12.7k51444 asked Oct 18 '11 at 6:10Razz315 25% accept rate.
– Jordan Oct 18 '11 at 6:17 1 I couldn't get any idea about how to do this, please help me! – Razz Oct 18 '11 at 6:55 I found the SQl query- select merchant_id,name, COUNT(*) AS no_of_reviews from reviews a, merchants be where a. Merchant_id=b.id GROUP BY merchant_id ORDER BY COUNT(merchant_id) DESC – Razz Oct 18 '11 at 8:06.
I found the answer: merchants = merchants. Includes(:reviews). Order("COUNT(reviews.
Merchant_id) DESC"). Group("merchant_id").
Thank you very much! – Razz Oct 21 '11 at 7:09.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.