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 8498729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:28:55+00:00 2026-06-11T00:28:55+00:00

I want to do a query that will count all the ’email’ rows in

  • 0

I want to do a query that will count all the ’email’ rows in my table and return all the values based on frequency. I don’t want to group the results though, I want to show every variation of the result, here is what I have so far, as you can see it sorts by frequency but merges them by group, I’d just prefer to show them all but in order of frequency.

select email 
from uploads 
group by email
order by count(*) desc

SQL –

CREATE TABLE uploads 
(
 email varchar(200)
);

INSERT INTO uploads
(email)
VALUES
('test@email.com'),
('test@email.com'),
('test@email.com'),
('test2@email.com'),
('test2@email.com'),
('test3@email.com'),
('test4@email.com');

Here Is the result I’d like

|              EMAIL |
----------------------
|    test@email.com  |
|    test@email.com  |
|    test@email.com  |
|    test2@email.com |
|    test2@email.com |
|    test3@email.com |
|    test4@email.com |
  • 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. Editorial Team
    Editorial Team
    2026-06-11T00:28:57+00:00Added an answer on June 11, 2026 at 12:28 am

    You can join against a subquery that returns an aggregate COUNT() per email and order by the descending count:

    SELECT 
      uploads.EMAIL
    FROM
      uploads 
      JOIN (
        /* subquery returns distinct emails and their aggregate COUNT() */
        /* JOIN matches every row in `uploads` to the email and count */
        SELECT EMAIL, COUNT(*) as num FROM uploads GROUP BY EMAIL
      ) c ON uploads.EMAIL = c.EMAIL
    ORDER BY 
      c.num DESC, 
      EMAIL ASC
    

    Effectively, this produces a result like the following, though you don’t actually include the num column in the SELECT list:

    |              EMAIL | num |
    ----------------------------
    |    test@email.com  | 3
    |    test@email.com  | 3
    |    test@email.com  | 3
    |    test2@email.com | 2
    |    test2@email.com | 2
    |    test3@email.com | 1
    |    test4@email.com | 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the above sample data, i want to write a query that will return
I want to know number of rows that will be affected by UPDATE query
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that
I'm trying to create a query that will return all the jobs published by
I want to add an extra field to my query that will have the
I want to get lambda function that will query for items which were submitted
I want to efficiently check if a table contains any rows that match <condition
What I have is a mySQL query that will select some drinks and return
I'm trying to put together a MYSQL query that will count the number of
I am trying to create a query that will list all books by the

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.