[SOLVED] How can i apply group by after applying limit in mysql?


I am trying to run the below query but it is wrong as per MySQL syntax.
I want to select the first 100 rows then want to apply group by to it.

select customerid from customer
limit 100
group by customerid

How can I achieve it?


How about this? You need to add an aggregation column for it to work.

SELECT customerid
        FROM   customer
        LIMIT  100) sub1
GROUP  BY sub1.customerid; 

Answered By – Darshit Parmar

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *