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 model : public class ContratoDetailsViewModel { [StringLength(50)] [RegularExpression(^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$)] [DisplayName(E-Mail Adm.)]
I have the following ajax call to update a particular field of a model
I have some action. I want send mail. usually i doing this way. public
I have this mail script I have to run a few times. To start
I have a mail webform where I have to show the user only (-1)
Is there some way to have the Mail Merge capability in my application? Maybe
I have an HTML Mail template, with a place holder for the image. I
I have an e-mail template which is just a plain, static HTML page. I
I have a e-mail address validator but I need to add special characters as
I have a php mail script sitting on a LAMP vps server. The script

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.