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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:03:12+00:00 2026-06-02T01:03:12+00:00

Ok, so I have the following database: CREATE TABLE IF NOT EXISTS `highscores` (

  • 0

Ok, so I have the following database:

CREATE TABLE IF NOT EXISTS `highscores` (
  `lid` int(11) NOT NULL,
  `username` varchar(15) NOT NULL,
  `score` int(16) NOT NULL,
  PRIMARY KEY  (`lid`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

lid being the level id.

lets say I have the following values in the table:

lid, username,score

1,sam,15 
1,joe,12
1,sue,6
1,josh,9
2,sam,8
2,joe,16 
2,sue,4
3,sam,65 
4,josh,87 
4,sue,43
5,sam,12
5,sue,28
5,joe,29
and so on.

How would I create a query(or if required a set of queries) to get the following

sam has 3 high scores
joe has 2 high scores
josh has 1 high score 

Thanks in advance.

  • 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-06-02T01:03:14+00:00Added an answer on June 2, 2026 at 1:03 am

    i have not tested it, but try the following query

    select 
        concat(h.username ," has ", count(h.username)," high scores ")
    from
        highscores h inner join
        (select lid, max(score) as maxscore
         from highscores group by lid) t on h.lid = t.lid and h.score = t.maxscore
    group by h.username
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following sample database set up - CREATE TABLE IF NOT EXISTS
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have the following table declared in MySQL: CREATE TABLE IF NOT EXISTS `ci_sessions`
I have a database with 2 tables: Table 1: CREATE TABLE IF NOT EXISTS
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
I have the following table and sequence in my postgresql-8.4 database: CREATE TABLE complexobjectpy
I have created an sqlite table using the following statement: CREATE TABLE IF NOT
If i have this table on dataBase.js file: client.query( 'CREATE TEMPORARY TABLE IF NOT
I have the following database -- MYSQL DROP TABLE IF EXISTS Attributes; DROP TABLE
I have a mysql table like this (sql): CREATE TABLE IF NOT EXISTS silver_and_pgm

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.