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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:57:16+00:00 2026-05-23T16:57:16+00:00

I am working on a MYSQL, and I am looking for a solution to

  • 0

I am working on a MYSQL, and I am looking for a solution to show data grouping by ratio.

I have a COURSE table which contain courses id and courses ratio. I have another table, ASK, which contain askers id, and another field course id pointing on COURSE table (ids correspond). With one SQL query, I would like to display all asks grouping by ratio and rejecting other demands. Demands are considered by seniority list.

By example, I have 3 courses: the first one allow only 2 people and 2 other courses allow only one person. In the ASK table, we have 3 askers (JACK, JOE AND JOHN) pointing on first course, (JOHN AND JOE) 2 on second and third (JACK AND JOHN). JACK is the older, after its JOHN and after its JOE.

I would like to see:

course id   studentName 
-------------------------
1           JACK         
1           JOHN            
2           JOHN
3           JACK
  • 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-23T16:57:16+00:00Added an answer on May 23, 2026 at 4:57 pm
    SELECT c.courseID
           s.studentName
    FROM course AS c
        JOIN asks AS a
            ON a.courseID = c.courseID
        JOIN student AS s
            ON s.studentName = a.studentName
        JOIN asks AS a2
            ON a2.courseID = c.courseID
        JOIN student AS s2
            ON s2.studentName = a2.studentName
            AND s2.seniority <= s.seniority
    GROUP BY c.courseID
           , c.ratio
           , s.studentName
    HAVING c.ratio >= COUNT(*)
    ORDER BY c.courseID
           , s.seniority
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any idea why the following code is not working mysql credentials are correct, have
I'm working with a MySQL database that has some data imported from Excel .
Can a PHP script (which can be working with a MySQL DB) send and/or
I have been working on a project that takes a MySQL dump and restores
I'm looking for the best way to implement the following. I have a MySQL
I am working on PHP and Zend. I have to show different type of
I'm working on improving the performance of a MySQL server. I'm looking for something
I'm working on a Linux/Apache/MySQL/Grails application and have the choice of build tools. I'm
The code in the sequence is working fine, but looking to improve the MySQL
Just looking for better solution.I'm retrieving all the records from mysql. Then I will

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.