Avatar of Ganesh Thandapani
Ganesh Thandapani
 asked on

MySQL to get Limited value from each category.

I have user table which contains user_name, import_id, user_category

user_name   import_id   user_category
aaaaa                 1                 1
bbbbbb              1                 1
aaaaa                 1                 1
bbbbbb              1                 1
aaaaa                 1                2
bbbbbb              1                 2
aaaaa                 1                 2
bbbbbb              1                 2
aaaaa                 1                 3
bbbbbb              1                 3
aaaaa                 1                 3
bbbbbb              1                 4
aaaaa                 1                 4
bbbbbb              1                 5

in which i have to show only two values in each category as a result
SQLMySQL Server

Avatar of undefined
Last Comment
Sharath S

8/22/2022 - Mon
Patrick Bogers

Hi

Can you be a little more specific about the output you expect?
Ganesh Thandapani

ASKER
simply i have to show only two result for each category, not all the result
ASKER CERTIFIED SOLUTION
Sharath S

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
arnold

Is the output you want
aaaaa,1,1
aaaaa,1,2
As an example?
The distinct option example will eliminate duplicates which you have!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Ganesh Thandapani

ASKER
ok nice, the distinct is used to avoid duplicates. Another condition if i want to take two or three values for each category how can i do that, any idea please.
Sharath S

Post your expected result.