I want to get top 10 most repeated values in a column of my table, I can do so using sql but I need to do it using CRUD i.e using collections or model as magento coding standard doesn't allow naked sql queries (MEQP1.SQL.RawQuery.FoundRawSql) - documentation

How would I go about doing so? Please point me in the right direction.

Thanks in advance!


Following is the sql query which can be used to do just what is required ..

SELECT `tag`, COUNT(`tag`) AS `value_occurrence` FROM `Faq_Tags` GROUP BY `tag` ORDER BY `value_occurrence` DESC LIMIT 10

I know how to order by, group by and set limit using magento collection but I am still not able to figure out how to get count('tag') using collection. Please help me regarding this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.