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

  • SEARCH
  • Home
  • 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 8904929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:15:44+00:00 2026-06-15T02:15:44+00:00

If I apply a limit when selecting with group by, the limit is applied

  • 0

If I apply a limit when selecting with group by, the limit is applied to the number of groups returned or the number of rows?

Myself, I want to limit the groups returned.

Here’s my trial:

select * from orders group by customer_email limit 0,2

From this table:

id customer_email
0 a@a.com
1 a@a.com
2 a@a.com
3 b@b.com
4 c@c.com
5 c@c.com
6 d@d.com

I want returned rows 0,1,2,3,4,5.

  • 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-15T02:15:45+00:00Added an answer on June 15, 2026 at 2:15 am

    Your question is a little ambiguous: the proposed query limits to 2 groups, and you seem to want all the rows with equal customer_email that are contained in the first 3 groups.

    Anyway, here is my answer for as far as I correctly understand your question 🙂

    SELECT *
    FROM orders
    INNER JOIN (
        SELECT customer_email
        FROM orders
        GROUP BY customer_email
        LIMIT 0,3
    ) AS temp
    ON orders.customer_email = temp.customer_email
    

    The sub query select customer_email from orders group by customer_email limit 0,3 selects the first 3 groups, then you select all the rows in order that contain the same customer_email as in the first 3 groups which would give you row 0, 1, 2, 3, 4, 5.

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

Sidebar

Related Questions

i want to limit the border length applied to a div element(or any HTML
select gmt from history.cachemap order by gmt asc limit 0,1; ..this returns gmt: 2012-05-03
Is there a way to limit the rows returned at the Oracle datasource level
SELECT (SELECT date FROM forums WHERE topic_id=f.id OR id=f.id ORDER BY id DESC LIMIT
What limit should be placed on the number of rows to delete in a
Symbian has a stack limit of 8kB. Does this also apply to the function
I want to apply texture to the transparent png(bitmap), but I don't want to
Just wondering does the 4GB limit apply to this edition or is it 'fully
When IE does Ajax, does the 2k length limit still apply for URL? (or
Is there a limit to the maximum number of concurrent users connected to SQL

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.