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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:18:09+00:00 2026-05-14T07:18:09+00:00

<hyperbole> Whoever answers this question can claim credit for solving the world’s most challenging

  • 0

<hyperbole>Whoever answers this question can claim credit for solving the world’s most challenging SQL query, according to yours truly.</hyperbole>

Working with 3 tables: users, badges, awards.

Relationships: user has many awards; award belongs to user; badge has many awards; award belongs to badge. So badge_id and user_id are foreign keys in the awards table.

The business logic at work here is that every time a user wins a badge, he/she receives it as an award. A user can be awarded the same badge multiple times. Each badge is assigned a designated point value (point_value is a field in the badges table). For example, BadgeA can be worth 500 Points, BadgeB 1000 Points, and so on. As further example, let’s say UserX won BadgeA 10 times and BadgeB 5 times. BadgeA being worth 500 Points, and BadgeB being worth 1000 Points, UserX has accumulated a total of 10,000 Points ((10 x 500) + (5 x 1000)).

The end game here is to return a list of top 50 users who have accumulated the most badge points.

Can you do it?

  • 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-14T07:18:10+00:00Added an answer on May 14, 2026 at 7:18 am

    My sample tables are:

    user:

    +-------+--------------+------+-----+---------+-------+
    | Field | Type         | Null | Key | Default | Extra |
    +-------+--------------+------+-----+---------+-------+
    | id    | int(11)      | YES  |     | NULL    |       |
    | name  | varchar(200) | YES  |     | NULL    |       |
    +-------+--------------+------+-----+---------+-------+
    

    badge:

    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    | score | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    

    award:

    +----------+---------+------+-----+---------+-------+
    | Field    | Type    | Null | Key | Default | Extra |
    +----------+---------+------+-----+---------+-------+
    | id       | int(11) | YES  |     | NULL    |       |
    | user_id  | int(11) | YES  |     | NULL    |       |
    | badge_id | int(11) | YES  |     | NULL    |       |
    +----------+---------+------+-----+---------+-------+
    

    Thus the query is:

    SELECT user.name, SUM(score)
      FROM badge JOIN award ON badge.id = award.badge_id
           JOIN user ON user.id = award.user_id
     GROUP BY user.name
     ORDER BY 2
     LIMIT 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a C++ graphing library that can display visual graphs (such as hyperbolas
In Python using wxPython, how can I set the transparency and size of a
I need advice. I'm writing a calculator; I've got the basic functionality of it
I have searched the knowledge base high and low, but nothing seems to give
Ok, so here's my problem. We are looking at purchasing a data set from
When Xcode makes it's auto-snapshots, prior to a global find-and-replace for instance, the snapshot
I'm new to Neural Networks, and programming generally. I've written a neural network in
In R, is there a way to plot 2D curves given by equations? For
I want to show a specific view in my RCP application using a command.
I was wondering if anyone knows a good library for tessellating a hyperbolic plane

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.