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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:01:07+00:00 2026-05-25T11:01:07+00:00

If my DATA sample is team name score1 score2 Adele’s 15 18 Madonna 16

  • 0

If my DATA sample is

team name  score1  score2
Adele's     15      18
Madonna   16       3
Britanny    9        12

How can I get a top 5 list of scores using both columns –
my output should be

Adele's   18
Madonna   16
Adele's   15
Britanny  12
  • 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-25T11:01:07+00:00Added an answer on May 25, 2026 at 11:01 am

    Derek Kromm’s answer needs a slight modification to avoid a bug when a team has two identical scores in the top 5 (e.g. same as the example, except Madonna score1 and score2 are both 16). The default behavior of union is to remove duplicate rows, so only one of the scores would be kept. Based on the question, I don’t think this is the desired behavior. Addition of the ‘all’ keyword to union will prevent this bug.

    select * from (
      select team, score1 from tbl
      union all select team, score2 from tbl) a
    order by score1 desc
    limit 5;
    

    I would have posted this as a comment to Derek Kromm’s answer, except that I don’t have enough reputation to do so. Sorry if posting it as an answer is not the correct etiquette.

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

Sidebar

Related Questions

Sample data: !!Part|123456,ABCDEF,ABC132!! The comma delimited list can be any number of any combination
I have the following sample data: Id Name Quantity 1 Red 1 2 Red
How can you use the following sample data either with a foreach or while
Sample Data: 603 Some garbage data not related to me, 55, 113 -> 1-ENST0000
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
Below is my sample data.MY environment is centos and I have run this command
Following is the sample data set that I need to group together, if you
Following is the sample data. I need to make 3 copies of this data
I want to sample data based on a timestamp field. I am reading huge
Here is the sample data for test table I have [childId] [parentId] [present] 1

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.