Hi all,
What is the best way to limit like the number of users per U.S. state to 5 or less?
Let's say that I have a table where I have like:
User State
---------------
test1 AL
test2 AL
test3 CO
test4 AL
test5 CO
test6 CO
test7 CO
test8 AL
test10 CO
test11 CO
test12 AL
test13 AK
test14 AK
test15 AK
I want a result set of like:
test1 AL
test2 AL
test4 AL
test8 AL
test12 AL
test13 AK
test14 AK
test15 AK
test3 CO
test5 CO
test6 CO
test7 CO
test10 CO
What would be a query to do something like that? Note it doesn't include ALL but it includes 5 or less broken by state. I would imagine there would be a GROUP BY but I can't get something to work.
Any assistance would be greatly appreciated.
Thanks
What is the best way to limit like the number of users per U.S. state to 5 or less?
Let's say that I have a table where I have like:
User State
---------------
test1 AL
test2 AL
test3 CO
test4 AL
test5 CO
test6 CO
test7 CO
test8 AL
test10 CO
test11 CO
test12 AL
test13 AK
test14 AK
test15 AK
I want a result set of like:
test1 AL
test2 AL
test4 AL
test8 AL
test12 AL
test13 AK
test14 AK
test15 AK
test3 CO
test5 CO
test6 CO
test7 CO
test10 CO
What would be a query to do something like that? Note it doesn't include ALL but it includes 5 or less broken by state. I would imagine there would be a GROUP BY but I can't get something to work.
Any assistance would be greatly appreciated.
Thanks