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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:00:58+00:00 2026-05-29T06:00:58+00:00

I have a Users table with these values (stripped down for the example): Name

  • 0

I have a Users table with these values (stripped down for the example):

  • Name
  • City
  • County
  • StateProvince
  • Country
  • Continent
  • Strength
  • Endurance
  • Intelligence

I basically want a query that returns the highest stat by region for yourself. If you have the highest Strength (67) in the country, highest Endurance (59) in your City, and not the highest Intelligence anywhere, I’d like a 2 row result of:

(‘Strength’, 67, ‘Country’, ‘United States’)

(‘Endurance’, 59, ‘City’, ‘Redmond’)

Note that if you have the highest Strength in the country, you will also have the highest strength in the state/province, county, and city (but I’d like those not to be returned in the result). I can do this all using multiple SELECT queries, however, I’d like to know how to do this in one single query for efficiency (or if that’s even a good idea?). I’d imagine the logic would go something like (pseudo code):

(SELECT FROM Users ORDERBY Strength WHERE Country = ‘MyCountry’ LIMIT 1) IF Name != ‘Me’ (SELECT FROM Users ORDERBY Strength WHERE StateProvince = ‘MyState’ LIMIT 1) … and so on

Furthermore, the above would also need to work with Endurance and Intelligence. Thanks!

  • 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-05-29T06:00:59+00:00Added an answer on May 29, 2026 at 6:00 am

    Check this link MySQL control-flow-functions

    SELECT CASE 1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'more' END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirements : I have a table of several thousand questions. Users can view these
if i have this table: users ----- id_users (pk) age name gender salary it
I have users table. There are three other tables: developers, managers, testers. All of
i have users table and i have posts table i want select from users
I have a table users which has a primary key userid and a datetime
I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId],
I have a table Users and a table Items In the Items table, I
I have a table called UserPermissions with a FK to the users table by
I have a items table with 1 million rows and a users table with
I have a USERS table. Each user has connections in a CONNECTIONS table. Each

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.