Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 124769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:03:10+00:00 2026-05-11T05:03:10+00:00

I have a Mail model with the following schema: t.string mail t.integer country t.boolean

  • 0

I have a Mail model with the following schema:

t.string   'mail' t.integer  'country' t.boolean  'validated' t.datetime 'created_at' t.datetime 'updated_at' 

And I want to find the top 5 countries in the database, so i go ahead and type

@top5 = Mail.find(:all,:group =>  'country',:conditions => [ 'validated = ?' , 't' ], :limit => 5 ) 

This will tell me the groups(i need an order by i dont know how to write)

@top5 = Mail.count(:all,:group =>  'country',:conditions => [ 'validated = ?' , 't' ], :limit => 5 ) 

This will tell me how many mails are in each group

Im wondering if i can group and count in just one go

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:03:11+00:00Added an answer on May 11, 2026 at 5:03 am
     Mail.find(     :all,      :select => 'count(*) count, country',      :group => 'country',      :conditions => ['validated = ?', 't' ],      :order => 'count DESC',     :limit => 5) 

    This should give you records that have a country attribute and a count attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form. How can I check the password from the user
I have the following simplified ViewModel public class UserViewModel : IUserViewModel { public DelegateCommand<object>
I have _Layout.cshtml defined for my mvc application, which is shown below: @inherits System.Web.Mvc.WebViewPage
I am having a slightly odd problem with sending mail in test mode with
I am using an Android Intent with ACTION_SEND and EXTRA_STREAM to share a generated
When you start a new project (whether it's personal or professional) what do you
My application is emailing out fine but the email I receive displays incorrectly. Rather
I am evaluating some web application frameworks out there, and finally, two of the
Hey, I'm trying to implement a message system as used in social networks. The
I am using Spring MVC for my web application and I am using my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.